Failed to connect Android client with local XMPP server

This refers to the post here.

I can connect my computer to the local tigase server setup locally (I use the Smack API). Now I encounter problems when I want to connect Android Phone to this server via Wi-Fi. I can connect to the local server using the Beem client for android.My XMPP. The server domain name is my computer name "mwbn43-1", and the IP address is "192.168.0.221" (I can ping from this server with Android Terminal Emulator). In the Beem settings there is an Advanced option, where I can specify the server with which I want to connect (which I gave as an IP address). If I do not set this parameter, I cannot connect. Below is a snippet of the code that I used for my android client.

    XMPPConnection.DEBUG_ENABLED = true;
    ConnectionConfiguration config = new ConnectionConfiguration("mwbn43-1",5222);

    //ConnectionConfiguration config = new ConnectionConfiguration("192.168.0.221",5222);             
    config.setSASLAuthenticationEnabled(false);
    config.setCompressionEnabled(false);

    XMPPConnection xmpp = new XMPPConnection(config);

    try {

            xmpp.connect(); 

            xmpp.login("admin@mwbn43-1", "tigase");
            String host = xmpp.getHost();
            String id = xmpp.getConnectionID();
            int port = xmpp.getPort();
            boolean i = false;
            i = xmpp.isConnected();
            if(i)
            {answer = "Connected to " + host + " via port " + port + " with ID " + id;
            answerfield.setText(answer);}

          }//end try 
    catch (XMPPException e) {  
     answerfield.setText("Failed to connect");
     Log.v(TAG, "Failed to connect to " + xmpp.getHost());
            e.printStackTrace();

google . , IP-, . IP- (192.168.0.221), " " : ( host-unknown), (mwbn43-1), "remote-server-timeout (504)" .

Beem, , , . . -, , , .

+3
5

3 ConnectionConfiguration. , . . , :

ConnectionConfiguration config = 
  new ConnectionConfiguration("192.168.0.221",5222,"mwbn43-1");
+6

.

,

connection.login("username", "password");

connection.login("username@host.com", "password");
+2
0

ConnectionConfiguration. .

For example, see below code:

ConnectionConfiguration config = new ConnectionConfiguration("hostname/IP address", 5222, "servicename/domainname");  
connection = new XMPPConnection(config);  
connection.connect();  
connection.login("user1", "password");`
0
source

Make sure you specify the correct permission: android.permission.INTERNET

0
source

Source: https://habr.com/ru/post/1749629/


All Articles