0

SMACKException: The following addresses failed: 'localhost:5222' failed because java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 5222) after 30000ms: isConnected failed: ECONNREFUSED (Connection refused)

   XMPPTCPConnectionConfiguration.Builder config =     
   XMPPTCPConnectionConfiguration
            .builder();
    config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
    config.setServiceName("localhost");
    config.setHost("localhost");
    config.setPort(5222);
    config.setDebuggerEnabled(true);
    XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);
    XMPPTCPConnection.setUseStreamManagementDefault(true);
    connection = new XMPPTCPConnection(config.build());
    XMPPConnectionListener connectionListener = new     
    XMPPConnectionListener();
    connection.addConnectionListener(connectionListener);

Please help me on it. Thanks in Advance

chank007
  • 240
  • 2
  • 8

1 Answers1

0

Since you have not specified your are connecting to server from device or emulator and I guess you are using your application in emulator.

If you are referring your localhost on your system from the Android emulator then you have to use http://10.0.2.2:8080/ Because Android emulator runs inside a Virtual Machine therefore here 127.0.0.1 or localhost will be emulator's own loopback address.

Refer:http://developer.android.com/tools/devices/emulator.html#emulatornetworking

See this answer:java.net.ConnectException: localhost/127.0.0.1:8080 - Connection refused

Community
  • 1
  • 1
Däñish Shärmà
  • 2,891
  • 2
  • 25
  • 43