Home > Mobile >  Can't connect openfire server
Can't connect openfire server

Time:03-17

The code is as follows:
New Thread (new Runnable () {
@ Override
Public void the run () {
//to establish connection with openfire server
XMPPTCPConnectionConfiguration. Builder configBuilder=XMPPTCPConnectionConfiguration. Builder ();
//set the XMPP domain name
Try {
ConfigBuilder. SetXmppDomain (" 127.0.0.1 ");
} the catch (XmppStringprepException e) {
e.printStackTrace();
}
//set the host position (i.e., server IP)
Try {
InetAddress address=InetAddress. GetByName (" 127.0.0.1 ");
ConfigBuilder. SetHostAddress (address);
} the catch (UnknownHostException e) {
e.printStackTrace();
}
//set the port number
ConfigBuilder. SetPort (5223);
//Settings are not validated, or TLS need validation
ConfigBuilder. SetSecurityMode (ConnectionConfiguration. SecurityMode. Disabled);
//set change user current state (online, offline, etc.)
ConfigBuilder. SetSendPresence (false);
/* configBuilder. SetUsernameAndPassword (" admin ", "xuan99102400.. "); */
AbstractXMPPConnection connection=new XMPPTCPConnection (configBuilder. The build ());
//to connect to the server
Try {
Connection. The connect ();
} the catch (SmackException e) {
Falied Logger. GetLogger (" ");
e.printStackTrace();
}


The exception thrown as follows:
Org. Jivesoftware. Smack. SmackException $ConnectionException: The following addresses failed: 'null: 5223' failed because:/127.0.0.1 exception: java.net.ConnectException: failed to connect to/127.0.0.1 (port 5223) from/127.0.0.1 (port 41318) after 30000 ms: isConnected failed: ECONNREFUSED (Connection refused)

Spark can connect to the server, can be the cause of the android emulator,
  • Related