File Transfer from a client behind a Nat

Hi everyone!!

I am using Smack to create a very simple client. I have no problems when using IM, but the problem comes when I try to receive a file from a client like PSI behind a NAT. When Smack tries to create a connection to receive the file, it is using the private IP of the PSI client instead of the public IP of the router, so the transfer never works. Why is Smack doing this?

I would really appreciate your help.

Thanks!!

Just adding some info: when using Empathy and trying to send a file to my client it says: “contact doesn’t have file transfer capabilities”.

Message was edited by: Solaiemes. Wrong Direction of Transfer…

I am still stucked with this problem. I’ve been investigating how different XMPP clients work. When sending a file between two PSI clients I’ve seen that not only the file sender sends its IP to the receiver but also does the receiver to the sender. Is this allowed?? Why does not smack do this??

Thanks!!!

Smack 3.2. has changed the file transfer procedures quite a bit. There are basiacally three options for file transfer

  1. Bytestream

  2. IBB with message stanzas

  3. IBB with IQ stanzas

Smack 3.2 uses 1) and 3). Smack 3.1 uses 1) and 2) Depending on the capabilities of your client, you may run in a problem using IBB. This is the fall back transfer mode, if bytestream is not working.

Thanks for your answer!

The point is that even when IBB is supported, it is never used when bytestreams fails.

This is what happened after a failure:

Sent:

<iqid="purpleaf9d229b"to="xxxxxxxxxxxxx@gmail.com/C5F70814"from=“xxxxxxxxxxxxx2@gmail.com/Solaiemes” type=“error”>

<query xmlns="http://jabber.org/protocol/bytestreams"sid=“purpleaf9d229a” mode=“tcp”>

<streamhost jid=" xxxxxxxxxxxxx@gmail.com/C5F70814"host=“192.168.0.170” port=“34926”/>

<streamhost jid="proxy.eu.jabber.org"host=“91.121.109.155” port=“7777”/>

<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"xml:lang=“en”>Could not establish socket with anyprovided host

Rcvd:

<iqid="purpleaf9d229c"to="xxxxxxxxxxxxx2@gmail.com/Solaiemes"from=“xxxxxxxxxxxxx@gmail.com/C5F70814” type=“set”>

<open xmlns="http://jabber.org/protocol/ibb"block-size=“4096” sid="purpleaf9d229a"stanza=“iq”/>

The first message is what my Smack client sent after a bytestreams failure, and the second message is what I received from Pidgin as an answer. Smack just ignored this message.

Appart from this I don’t know whether I am right or wrong about how bytestreams works when using a proxy like proxy.eu.jabber.org. When you are using this kind of transmission, do both sides of the transmission need to open a connection to the proxy, don’t they? In that case, I always see Smack trying to open the connection but the other side never does… How does the other participant know that the connection to the proxy has to be opened??

Thanks in advance!!

Hi Solaiemes,

can you please post the disco#info and disco#items messages for me?

Hi!!

This is the sequence:

Rcvd by Smack:

<iqid="purpleaf9d2298"to="xxxxxxxxxxxx2@gmail.com/Solaiemes"from=“xxxxxxxxxxxx@gmail.com/C5F70814” type=“get”>

Sent:

<iqid="purpleaf9d2298"to="xxxxxxxxxxxx@gmail.com/C5F70814" type=“result”>

<identity category=“client” name="Smack"type=“pc”/>

<featurevar=“http://jabber.org/protocol/si/profile/file-transfer”/>

This is all I have about disco#info (there is no disco#items) for this case, that is receiving a file from Pidgin in my own client.

I have added a STUN server in Pidgin. As a result IBB now is possible. Now it is trying to establish a connection with both, the public router address (given by the STUN server) and the private computer address, and as it fails IBB occurs.

If I remove the STUN server and no proxy is configured, both IBB and bytestreams fail. What I have seen in Wireshark is that my computer (with public IP) is trying to connect to the private IP address, 192.168.0.170, where Pidgin is installed, once and again. I know this is quite weird but is what I have seen.

To receive a file using bytestreams, which ports need to be opened in my router??

By the way, if you try to send disco#items to gmail.com, what you receive is 501, feature-not-implemented, and file transfer won’t happen.

Thanks!!

Ok, my fault!!!

If you want to use bytestreams behind nat just try to find a proxy server that works. It was always trying to use proxy.eu.jabber.org but never worked. It could connect to it but then things went wrong.

When sending a file to a gmail account from Smack, disco#items answer is 501, so I decided to change this query to jabber.org everytime I see a disco#items addressed to gmail.com.

For Pidgin to work using IBB, I configured its STUN server. Even when I know this wont work for bytestreams I don’t know the reason but the fact is that when bytestreams fails IBB occurs… If I just send my private IP to Smack it won’t work.

I hope this will help you. Of course there are some problems to correct but at least it seems to work fine now.

Thanks!!