File transfer failure (Could not establish socket with any provided host)


I’'m having problems with file transfers. The problem occurs in the following scenario:

  • User1 sends User2 some file. This usually works.

  • User2 now sends User1 some file. This randomly fails with the following exception:

Could not establish socket with any provided host: (406)

at org.jivesoftware.smackx.filetransfer.Socks5TransferNegotiator.selectHost(Socks5

at org.jivesoftware.smackx.filetransfer.Socks5TransferNegotiator.negotiateIncoming Stream(

at org.jivesoftware.smackx.filetransfer.FaultTolerantNegotiator.createIncomingStre am(

at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.negotiateStream(Incom

at org.jivesoftware.smackx.filetransfer.IncomingFileTransfer.recieveFile(IncomingF



at org.jivesoftware.smackx.filetransfer.FileTransferManager.fireNewRequest(FileTra

at org.jivesoftware.smackx.filetransfer.FileTransferManager$1.processPacket(FileTr

at org.jivesoftware.smack.PacketReader$ListenerWrapper.notifyListener(PacketReader .java:822)

at org.jivesoftware.smack.PacketReader.processListeners(

at org.jivesoftware.smack.PacketReader.access$100(

at org.jivesoftware.smack.PacketReader$

I am not able to completly reproduce the exception, but it occurs about every second try and always after the first file transfer finished succesfully.

Does anybody have any clue what might be causing this? Any pointers would be very appreciated.

Thanks a lot,

Riad Djemili


Is the transfer really failling ? This exception means that the Sock5 connection (direct connection between users) has failed, but Smack should switch to Inband File Transfer after that (and this should work).

Is there any NAT gateway between your 2 users ? are they on the same local network ?

are they using firewalls ?


Hi Nicolas,

I think the transfer is really failing, but I’'ll look into it and check back here.

About NAT: This occurs while running two instances of test programs on my desktop.


File transfers create a proxy server on your computer always using the same listening port (7777).

I think that on your second try, the port is still locked by the first user. So the proxy server can’'t start.

Try to use different computers for each user or patch your smack version with my file transfer patch that let you specify the port you want to use.

See this thread :


Message was edited by: nricheton


that might be it. Weird that it sometimes works and other times not, though. I’‘ll try your patch. Thanks a lot so far. I’'ll keep you posted.


sorry for not replying earlier. I was out of town.

Anyhow… I just tried your patch and it works like a charm. Thanks a lot!

That problem was driving me mad for about two months now.