Java.net.UnknownHostException when connecting openfire xmpp server

I am a beginner for chat. I started to study the chat application I'm trying to connect an Android virtual device to an openfire xmpp server, but I can’t connect, I get java.net.UnknownHostException can anyone help me connect my top xmpp server on an Android device?

The code I use is:

ConnectionConfiguration config = new ConnectionConfiguration("pc" ,5222);
    /*ConnectionConfiguration config = 
        new ConnectionConfiguration("192.168.0.1",5222,"pc");*/
    /*config.setCompressionEnabled(true);
       config.setSASLAuthenticationEnabled(true); */
    config.setSecurityMode(SecurityMode.disabled);
    config.setDebuggerEnabled(true);
    config.setSASLAuthenticationEnabled(false);
       XMPPConnection connection = new XMPPConnection(config);   
       Log.i("", "before connecting");
       connection.connect();
       Log.i("", "after connecting");
       //connection.login("test", "test");
    if(connection.isConnected()){
     System.out.println("connection built");
     connection.disconnect();
    }

in manifest:

<uses-permission android:name="android.permission.INTERNET"/>

and Logcat I have java.net.UnknownHostException.

0
source share
1 answer

We came up with a solution, @devil and I. We just used the IPv4 address of our server.

ConnectionConfiguration config = 
new ConnectionConfiguration("192.168.1.2",5222,"pc");
+2
source

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


All Articles