Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top