Kryonet on Android device

Anything about development not directly related to libgdx, e.g. OpenGL, Android APIs etc.

Kryonet on Android device

Postby Dudule » Wed Jan 29, 2020 9:35 am

Hello everybody,
I'm trying to develop a client/server application with kryonet, but i can't manage to make it working on android device. I did exactly what is said on https://github.com/EsotericSoftware/kryonet. It's working fine on desktop device between two PC on the same local network, but i have no result on android device.

My Server
Code: Select all
        server = new Server();
        Kryo kryo = server.getKryo();
        kryo.register(RqClass.class);
        kryo.register(RpClass.class);
        server.start();
        try {
            server.bind(54555, 54777);
        }
        catch(java.io.IOException e){System.out.println(e.getMessage());}

        server.addListener(new Listener() {
            public void received (Connection connection, Object object) {
                if (object instanceof RqClass) {
                    RqClass request = (RqClass)object;
                    receiveMessage(request.text);
                    sendMessage(connection,"envoyé");
                };;
            }
        });


My Client
Code: Select all
        client = new Client();
        Kryo kryo = client.getKryo();
        kryo.register(NetModule.RqClass.class);
        kryo.register(NetModule.RpClass.class);
        client.start();

        InetAddress address = client.discoverHost(54777, 5000);
        if (address==null){
            textArea.appendText("\nServeur introuvable");
            return;
        }
        System.out.println(address);

        try {
            client.connect(5000, address, 54555, 54777);
        }
        catch(java.io.IOException e){
            System.out.println(e.getMessage());
        }
        client.addListener(new Listener() {
            public void received (Connection connection, Object object) {
                if (object instanceof RpClass) {
                    RpClass reply = (RpClass)object;
                    receiveMessage(reply.text);
                }
            }
        });


And I gave the permission in the AndroidManifest.xml
Code: Select all
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


But the Client.discoverHost() method give a 'Host discovery timed out' message, the application can't find the running server. No more exception message.
It doesn't work even if I mention the local IP of the PC wich is running the Server, even if I use the '127.0.0.1' address instead of using discoverHost(). Because I test it on the same computer.
I tried to disable my firewal, no way.

I found a lot of similar issues on the net, but no solution.

Does someone managed to make kryonet work ? And how ? What did I forget ? Is my Android version in cause ?
Code: Select all
    buildToolsVersion "29.0.2"
    compileSdkVersion 29
...
        minSdkVersion 14
        targetSdkVersion 29    (I tried with 26)


I use the 2.22.0-RC1 version of kryonet.

Thanks a lot for your help.
Dudule
 
Posts: 20
Joined: Sun Aug 27, 2017 6:33 pm

Re: Kryonet on Android device

Postby shatterblast » Wed Jan 29, 2020 1:52 pm

Don't use Kryonet at all.
shatterblast
 
Posts: 653
Joined: Sun Jul 06, 2014 1:14 pm

Re: Kryonet on Android device

Postby Dudule » Wed Jan 29, 2020 1:57 pm

Ah, I thaught it was made for this...
So what should I use according to you ?
Thank's
Dudule
 
Posts: 20
Joined: Sun Aug 27, 2017 6:33 pm

Re: Kryonet on Android device

Postby shatterblast » Wed Jan 29, 2020 2:19 pm

Open Match and Firebase are better to start with. I should probably have my gpgs-libgdx repository ready in about two weeks or so. It may make connections easier, but I believe Android already provides support for those.

I think someone from EsotericSoftware asked me a year ago if Kryonet should stay up, and I said yes at the time. However, it's really bad at networking over wireless. It's a little more useful for Steam, but Wi-Fi still is horrible with Kryonet. It's time Kryonet left.
shatterblast
 
Posts: 653
Joined: Sun Jul 06, 2014 1:14 pm


Return to General Development

Who is online

Users browsing this forum: No registered users and 1 guest