0

尝试通过以下代码连接到openfire服务器时:

Connection connection = new XMPPConnection("https://192.168.0.101:5222");
connection.connect();

我得到一个例外,上面写着:

https://192.168.0.101:5222:5222 Exception: Could not connect 
to https://192.168.0.101:5222:5222.; : remote-server-timeout(504)

这可能是什么原因?

注意:我已经允许openfire fire服务器通过防火墙。我也尝试关闭防火墙,但结果相同。服务器是我自己的机器。我试图在其上运行程序的同一台机器。

4

3 回答 3

2

您可以使用

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

或者如果你想指定端口

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

或类似的,默认为端口 5222

ConnectionConfiguration config = new ConnectionConfiguration("192.168.0.101");
Connection connection = new XMPPConnection(config);
connection.connect();
于 2013-08-19T12:41:58.047 回答
0

尝试这个:

Connection connection = new XMPPConnection("localhost:5222");
connection.connect();
于 2013-08-17T05:17:05.267 回答
0

你可以参考这个:

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);
}

或者没有用于密钥库密码提示的回调处理程序:

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);
}

或者:

public XMPPConnection(ConnectionConfiguration config) {
    super(config);
}
于 2018-06-26T02:25:42.720 回答