Smack 3.0.4 File Transfer issues

I’ve found a couple of issues with file transfers in Smack 3.0.4.

First, if your login server doesn’t act as a file transfer proxy, the local host is not used as a proxy host; the transfer will always go inband. This is due to the initProxies() method in Socks5TransferNegotiatorManager class. If the XMPP server returns no proxy servers, the streamHosts object is not initialized and a NPE is thrown. Below is a fix that initializes the streamHosts object if not proxy servers are found.

Secondly, fail over to IBB often fails with out-of-the-box Smack settings. The issue is that the Sock5TransferNegotiator of the senders times out after 10 seconds, then the FaultTolerantNegotiator sends a request to go in-band. The receiver times out on the bytestream attempt after 10 seconds. But the FaultTolerantNegotiator times out in 10 seconds and the PacketCollector times out and the IBB request from the sender is not caught. The senders timeout is hard coded to 10 seconds. The receiver’s timeout is set to twice the Smack default wait time (5 seconds). I wondered why Spark wasn’t experiencing the same problem as my program: Spark sets the Smack default wait time to 10 seconds.



private void initProxies() {

proxies = new ArrayList<String>();

ServiceDiscoveryManager manager = ServiceDiscoveryManager


try {

DiscoverItems discoItems = manager.discoverItems(connection.getServiceName());

Iterator it = discoItems.getItems();

while (it.hasNext()) {

DiscoverItems.Item item = (DiscoverItems.Item);

String proxy = checkIsProxy(manager, item);

if (proxy != null) {





catch (XMPPException e) {



if (proxies.size() > 0) {



else {

streamHosts = new ArrayList<Bytestream.StreamHost>();




Thanks a lot, PouncePony! You really saved my day!