Java ';远程服务器超时';尝试连接到服务器时出现异常
尝试通过以下代码连接到openfire server时:Java ';远程服务器超时';尝试连接到服务器时出现异常,java,xmpp,openfire,smack,Java,Xmpp,Openfire,Smack,尝试通过以下代码连接到openfire server时: 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-serv
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 server通过防火墙。我也尝试过推迟防火墙,但结果相同。服务器是我自己的机器。我尝试在同一台机器上运行程序。请尝试以下操作:
Connection connection = new XMPPConnection("localhost:5222");
connection.connect();
你可以用
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();
您可以参考以下内容:
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);
}
或:
你的网络正常吗。。。已经在代码中检查过了。@karan421 123 123。。是的,它正在处理ip地址,查看响应时间,并查看即将使用的内容wireshark@SuhailGupta您无需输入端口。
new-XMPPConnection(“192.168.0.101”)
显示您正在使用的操作系统
public XMPPConnection(ConnectionConfiguration config) {
super(config);
}