0
votes

I have got an requirement to connect XMPP server using Java API Smack and further make send message/receive message.

I tried with Smack API (4.1.8) and I am getting errors (find errors below).

Note: both host and port are opened.

Code:`public class Sender {
public static void main(String a[]) throws NoResponseException,XMPPException,
InterruptedException, SmackException, IOException
{
    // Create the configuration for this new connection
   XMPPTCPConnectionConfiguration.Builder configBuilder =  XMPPTCPConnectionConfiguration.builder();
    configBuilder.setUsernameAndPassword("user", "******");
    configBuilder.setResource("work");
    configBuilder.setServiceName("HOstname");
    configBuilder.setSocketFactory(SSLSocketFactory.getDefault());
    configBuilder.setSecurityMode(SecurityMode.required);

    configBuilder.setCompressionEnabled(true);
    configBuilder.setHost("thingsociety.im");
    configBuilder.setDebuggerEnabled(true);
    configBuilder.setPort(5222);
    System.out.println("Connected1..............");

    XMPPTCPConnection connection = new XMPPTCPConnection(configBuilder.build());
    // Connect to the server
    try {
        System.out.println("Connected2..............");
        connection.setPacketReplyTimeout(100000);
        connection.connect();
        System.out.println("Connected3..............");
        // Log into the server
        connection.isConnected();
        connection.login();
        System.out.println("Connected4..............");
    }

    catch (XMPPException | SmackException | IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
         System.out.println(e.getMessage());
         }
    }
}

Error: No response received within reply timeout. Timeout was 100000ms (~100s). Used filter: No filter used or filter was 'null'. org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 100000ms (~100s). Used filter: No filter used or filter was 'null'

1

1 Answers

0
votes

So basicly something (local firewall or on your gateway) is blocking outgouing communications OR configBuilder.setServiceName("HOstname"); service name (aka XMPP Domain) is wrong, maybe mispelled - especialy capital O looks like misspell to me.

I have just probe thingsociety.im:5222 and it is open so most probably it is a firewall issue.

Another one could be unhandeld, low level error on server side.