'remote-server-timeout' exception as I try to connect to the server

99封情书 提交于 2019-12-02 12:44:19

You can use

Connection connection = new XMPPConnection("192.168.0.101");
connection.connect();

or if you want to specify the port

ConnectionConfiguration config = new ConnectionConfiguration("192.168.0.101", 5222);
Connection connection = new XMPPConnection(config);   
connection.connect();

or similar, defaulting to port 5222

ConnectionConfiguration config = new ConnectionConfiguration("192.168.0.101");
Connection connection = new XMPPConnection(config);
connection.connect();

try this:

Connection connection = new XMPPConnection("localhost:5222");
connection.connect();

You can refer to this:

public XMPPConnection(String serviceName, CallbackHandler callbackHandler) {
    // Create the configuration for this new connection
    super(new ConnectionConfiguration(serviceName));
    config.setCompressionEnabled(false);
    config.setSASLAuthenticationEnabled(true);
    config.setDebuggerEnabled(DEBUG_ENABLED);
    config.setCallbackHandler(callbackHandler);
}

or with no callback handler for password prompting of the keystore:

public XMPPConnection(String serviceName) {
    // Create the configuration for this new connection
    super(new ConnectionConfiguration(serviceName));
    config.setCompressionEnabled(false);
    config.setSASLAuthenticationEnabled(true);
    config.setDebuggerEnabled(DEBUG_ENABLED);
}

or:

public XMPPConnection(ConnectionConfiguration config) {
    super(config);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!