Search code examples
androidxmppsmack

Xmpp connection failed with smack


I currently have an android application in which I use the smack library to connect to my XMPP server. This application has already worked in the past, but since today, my tablet could not connect to the server.

On the line :

connection.connect();

I got this error :

W/System.err﹕ org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: '192.168.57.100:5222' failed because java.net.ConnectException: failed to connect to /192.168.57.100 (port 5222) after 30000ms: isConnected failed: EHOSTUNREACH (No route to host)

W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPConnection.java:596)
07-08 11:46:19.730  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:830)
07-08 11:46:19.730  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:360)
07-08 11:46:19.730  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at com.crisalid.EcranCuisine.PosteFabActivity$XMPPAsyncTask.doInBackground(PosteFabActivity.java:583)
07-08 11:46:19.730  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at com.crisalid.EcranCuisine.PosteFabActivity$XMPPAsyncTask.doInBackground(PosteFabActivity.java:284)
07-08 11:46:19.730  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:288)
07-08 11:46:19.730  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-08 11:46:19.731  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
07-08 11:46:19.731  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
07-08 11:46:19.731  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
07-08 11:46:19.731  13812-14023/com.crisalid.EcranCuisine W/System.err﹕ at java.lang.Thread.run(Thread.java:848)

There is strange things append : I installed this application on my tablet and on my phone. With exactly the same configuration, I don't get this error on my phone but I'm getting it on my tablet.

I already tried to disable/ enable my wifi on the tablet but nothings changes. I checked if the server was up, and it is working.

Have you any idea ?


Solution

  • Selvin were right, with my tablet I was connected to te right wifi but dhcp was attributing me a wrong ip. On my tablet the ip was 10.20.64.152 so it wasn't on the good network (which is 192.168.57.*).

    The solution was to set a static ip.