问题
While trying to connect to openfire server through the following code :
Connection connection = new XMPPConnection("https://192.168.0.101:5222");
connection.connect();
I get an exception which says :
https://192.168.0.101:5222:5222 Exception: Could not connect
to https://192.168.0.101:5222:5222.; : remote-server-timeout(504)
What could be the reason for this ?
Note : I have allowed openfire fire server through the firewall.I also tried putting off the firewall, but the same result.Server is my own machine. The same machine on which I am trying to run the program.
回答1:
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();
回答2:
try this:
Connection connection = new XMPPConnection("localhost:5222");
connection.connect();
回答3:
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);
}
来源:https://stackoverflow.com/questions/18285323/remote-server-timeout-exception-as-i-try-to-connect-to-the-server