8
votes

I have a Java application implementing Smack 4.1.7 that I am using as a mock client for Openfire 4.0.2. At the moment, Openfire is running on my localhost. Smack can login and authenticate properly with this connection:

XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder()
      .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
      .setServiceName(XMPP_HOST_NAME) // equals xmppDomain on server
      .setUsernameAndPassword("user1", "pwd1")
      .setResource("tester")
      .setDebuggerEnabled(true)
      .build();

Now when Smack tries to create or join a MUC, the request times out (SmackException$NoResponseException) and Openfire logs the following:

2016.07.03 18:58:54 org.jivesoftware.openfire.spi.RoutingTableImpl - 
Unable to route packet. Packet should only be sent to available sessions and the 
route is not available. 
<presence id="WrkXH-6" from="user1@localhost/tester" to="user1@localhost/tester">
    <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.igniterealtime.org/projects/smack" ver="NfJ3flI83zSdUDzCEICtbypursw="/>
</presence>
2016.07.03 18:58:54 org.jivesoftware.openfire.spi.RoutingTableImpl - 
Failed to route packet to JID: user1@localhost/tester packet: 
<presence id="WrkXH-6" from="user1@localhost/tester" to="user1@localhost/tester">
    <c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://www.igniterealtime.org/projects/smack" ver="NfJ3flI83zSdUDzCEICtbypursw="/>
</presence>

I have used "localhost", "127.0.0.1" and the name of my machine as XMPP_HOST_NAME both at the server side and the client side, and I keep getting the same error. Any help would be appreciated.

1
i'm sorry, have you done the login with the user? localhost will not work, machine name (but you have to check on openfire server name in control panel) will works. To me presence from and to the same person seems strange but I have to checkMrPk
yes, login works fine. It both works with localhost, 127.0.0.1 and machine name (no matter what is configured at openfire side btw). There is a warning at Smack side when establishing connection : org.jivesoftware.smack.util.DNSUtil resolveDomain WARNING: Exception while resovling SRV records for localhost. Consider adding '_xmpp-(server|client)._tcp' DNS SRV Records, but appart from that connection and authentication are ok.guik
Maybe you have a proxy and you have to add localhost (yes, 127.0.0.1) as exception...MrPk
@R_R Hi. Can I ask if you need openfire (or any other server) to get smack to work? I just want to run a simple example on my computer. Can you post your all the classes if it's easy for you? Or can you guide me to some tutorial? thanksFaraz

1 Answers

0
votes

I found the problem and a bug. How to handle:

Openfire has 2 values:

http.connection.timeout
http.socket.timeout 

both setted up with a default value of 2000/3000/5000 millisecs if not available in properties.

So it's needed to set this values by admin console (or database) to an higher one, like 15000/20000 or more if needed.

More, in Openfire 4.0.2 (ad probably older versions too) in index.jsp there's a call to check rssfeed (enabled by default) but this call will reset those values to 3000, so basically timeouts will be usless.

To disable rssfeed set to false

rss.enabled

And then restart Openfire.