Smack4.2.0:exception: java.net.SocketTimeoutException: connect timed out

smack 4.2.0+openfire 4.1.3 When it comes to the method “connection()”, it has always been like this:

org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: ‘192.168.1.112:5222’ failed because: /183.207.232.253 exception: java.net.SocketTimeoutException: connect timed out

My Android phone and laptop are in the same LAN

public class MainActivity extends AppCompatActivity {    @Override
   protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);    new Thread(new Runnable() {
   @Override
   public void run() {
   try {
  XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
  .setXmppDomain("192.168.1.112")
  .setHost("192.168.1.112")
  .setCompressionEnabled(false)
  .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
  .build();
  AbstractXMPPConnection conn = new XMPPTCPConnection(config);
  conn.connect();
  } catch (InterruptedException | IOException | SmackException | XMPPException e) {
  e.printStackTrace();
  }
  }
  }).start();
  }
}

Use setHostAddress() instead of setHost().

Hi
I also facing same problem , it was working , but after it is continuously giving same error

org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: ‘172.20.1.69:5222’ failed because java.net.SocketTimeoutException: failed to connect to /172.20.1.69 (port 5222) after 30000ms

Also I try with setHostAddress() metho but is not available.

Have you solved it now?