XMPPConnection constructor suggestion

Hi,

Here is the start of the constructor for XMPPConnection:

public XMPPConnection(String host, int port) throws XMPPException {

this.host = host;

this.port = port;

try {

this.socket = new Socket(host, port);

}

I would like to suggest an additional constructor, something like:

public XMPPConnection(String host, int port, InetAddress physicalHost) throws XMPPException {

this.host = host;

this.port = port;

try {

this.socket = new Socket(physicalHost, port);

}

This would decouple the hostname used in the JID from the hostname or ip

address used to connect the socket. Basically I would like to

distribute a smack app via java web start to clients that cannot

resolve the xmpp server’'s hostname. Getting the ip to them will be

easier than getting everyone’'s administrators to deal with

their name resolution problems. This is somewhat akin to the Psi

client’'s “Manually Specify Server Host/Port” feature.

Thanks

mkeller,

Thanks for your suggestion. We will evaluate it and, if possible, try to include it in the next release.

Thanks,

– Gato

We have a bug filed on this issue, but I’‘m not sure it’‘s actually a problem. The server will always use the host information provided by the server. So, if you connect to 192.168.1.1 and the server says it is “acme.com”, that’‘s what Smack will use subsequently. So, I don’'t think that a constructor that allows you to pass in an InetAddress is needed.

Regards,

Matt

Unfortunately, this doesn’'t work as desired (at least against the server at jabber.org)

import org.jivesoftware.smack.XMPPConnection;

class SmackTest {

public static void main(String[] args) throws Exception {

XMPPConnection con

= new XMPPConnection(“jabber.org”);

}

}

T 68.35.250.92:1089 -> 208.245.212.67:5222

<stream:stream to=“jabber.org” xmlns=“jabber:client” xmlns:stream="http://e

therx.jabber.org/streams">

T 208.245.212.67:5222 -> 68.35.250.92:1089

<stream:stream from=’‘jabber.org’’ xmlns=’‘jabber:client’’ id=’‘2FE5956827A43’’ x

mlns:stream=’‘http://etherx.jabber.org/streams’’>

import org.jivesoftware.smack.XMPPConnection;

class SmackTest {

public static void main(String[] args) throws Exception {

XMPPConnection con

= new XMPPConnection(“208.245.212.67”);

}

}

T 68.35.250.92:1092 -> 208.245.212.67:5222

<stream:stream to=“208.245.212.67” xmlns=“jabber:client” xmlns:stream="http

://etherx.jabber.org/streams">

T 208.245.212.67:5222 -> 68.35.250.92:1092

<stream:stream from=’‘208.245.212.67’’ xmlns=’‘jabber:client’’ id=’'2FF2740C6D5F

9’’ xmlns:stream=’‘http://etherx.jabber.org/streams’’>

I would call that a bug with the Jabber.org server. It seems like the proper behavior would be for it to return it’'s real name rather than the IP in this case.

Regards,

-Matt

I think I violated the protocol first though by sending to=“208.245.212.67” instead of to=“jabber.org”.

From the “work in progress” at http://www.ietf.org/internet-drafts/draft-ietf-xmpp-core-22.txt

4.2 Stream Attributes

The attributes of the stream element are as follows:

o to – The ‘‘to’’ attribute SHOULD be used only in the XML stream

header from the initiating entity to the receiving entity, and

MUST be set to a hostname serviced by the receiving entity.