neatorobito / Salut

A nice library for working with WiFi P2P service discovery on Android.
MIT License
297 stars 88 forks source link

serviceAddress is null #33

Open junzew opened 7 years ago

junzew commented 7 years ago

I am using Salut 0.5.0 and I have two client devices and a host successfully connected to each other. Communication between host and client works fine. However, when I invoke sendToDevice to try to send some data from one client to another client:

network.sendToDevice(anotherClientDevice, data, new SalutCallback() {
        @Override
        public void call() {
            Log.d(TAG, "send data to device failed");
        }
    }
);

I got the following exception: java.lang.IllegalArgumentException: host=null, port=4321 at java.net.InetSocketAddress.(InetSocketAddress.java:99) at java.net.InetSocketAddress.(InetSocketAddress.java:90) at com.peak.salut.BackgroundDataSendJob.doOnBackground(BackgroundDataSendJob.java:37) at com.arasthel.asyncjob.AsyncJob$2.run(AsyncJob.java:59) at java.lang.Thread.run(Thread.java:818)

It turns out that device.serviceAddress is null in BackgroundDataSendJob:

try {
     dataSocket.connect(new InetSocketAddress(device.serviceAddress, device.servicePort));
     // ...
}

The field Salut.serviceAddress seems to be not properly set in BackgroundClientRegistrationJob and BackgroundServerRegistrationJob.

Any thoughts on this?

VitorFontenelle commented 7 years ago

I have the same issue. If you got any answers, please share them here.

neatorobito commented 7 years ago

Can you try using 0.4.9? compile 'com.github.markrjr:Salut:v0.4.9'

VitorFontenelle commented 7 years ago

I have tried to downgrade to 0.5.0 and 0.4.9, and for some reason, in these versions the Client don't even discover the Host... I have ended up opening a new issue with more details on my specific case. https://github.com/markrjr/Salut/issues/35