WS connectionhandler object issue with onClose() callback on Samsung galaxy s4

#1

Hi,

I am facing an issue when I run my program on a Samsung Galaxy s4 device, I created a class that inherits WebSocketConnectionHandler. This class contains a WebSocketConnection object and when I want to test a connection loss the onClose() callback is never fired, then I tested it on other devices such as Acer or Asus and it works fine.

Is somebody having the same problem?

0 Likes

#2

Hi Karl,

I have tested with Samsung galaxy note, which is the same version of android os as S4 and my client and server worked fine. On connect and disconnect. Can you explain little more what are you using at client (JS) and will be great if you will attach some code for your server class handling connections and disconnections. We might help you better with code.

Keep coding with Autobahn. :slight_smile:

Thanks,

Chuck

···

On Monday, January 20, 2014 9:22:04 AM UTC-5, Karl Berger wrote:

Hi,

I am facing an issue when I run my program on a Samsung Galaxy s4 device, I created a class that inherits WebSocketConnectionHandler. This class contains a WebSocketConnection object and when I want to test a connection loss the onClose() callback is never fired, then I tested it on other devices such as Acer or Asus and it works fine.

Is somebody having the same problem?

0 Likes

#3

Hi Chuck,

Thanks for your reply and sorry for the long time I didn’t respond back. Though the problem stills here.
The client I’m using is a recent version of autobahn for android that I pulled from the github repo 10 days ago.

You can see in the following lines how I implemented my client:

So when the user logs in, I instanciate this class in a thread and there’s the constructor:

public ProxyClient(String hostip, int hostport) {

hostURL = “ws://:/ws”;

wsConnection = new WebSocketConnection();

wsConnectionHandler = new WebSocketConnectionHandler(){

@Override

public void onOpen() {

ProxyClient.this.onOpen();

}

@Override

public void onClose(int code, String reason) {

ProxyClient.this.onClose(code, reason);

}

@Override

public void onTextMessage(String payload) {

ProxyClient.this.onTextMessage(payload);

}

};

try {

wsConnection.connect(hostURL, wsConnectionHandler);

} catch (WebSocketException e) {

e.printStackTrace();

}

}

Then I wait for the connection to open, send my first message and everything works fine.

Now the fact is that the onClose() event doesn’t fire when I turn off the phone’s wifi (the phone is a galaxy s4 mini GT-i9195), so I decided to manage this in another way.

I implemented a class that extends from BroadcastReceiver to catch the intents fired on a connectivity action, when I receive those messages, I set the wsConnection object to null (I also make a call to the disconnect() method although this is useless in my case) and the wsConnectionHandler as well.

Then when I know that another connection type is available I instanciate a new WS connection handler and a new WS connection, everything seems to work well, I’m able to send a message with the new connection (the server gets the message and sends the response to the right address I checked that with tshark) but it seems that I cannot get any response on the client side in my new connection handler’s overriden methods.

So that makes one more problem added to the old one :D.

Do you have any advice about it?

Best regards

Karl

···

Le mardi 21 janvier 2014 17:35:21 UTC+1, Chuck James a écrit :

Hi Karl,

I have tested with Samsung galaxy note, which is the same version of android os as S4 and my client and server worked fine. On connect and disconnect. Can you explain little more what are you using at client (JS) and will be great if you will attach some code for your server class handling connections and disconnections. We might help you better with code.

Keep coding with Autobahn. :slight_smile:

Thanks,

Chuck

On Monday, January 20, 2014 9:22:04 AM UTC-5, Karl Berger wrote:

Hi,

I am facing an issue when I run my program on a Samsung Galaxy s4 device, I created a class that inherits WebSocketConnectionHandler. This class contains a WebSocketConnection object and when I want to test a connection loss the onClose() callback is never fired, then I tested it on other devices such as Acer or Asus and it works fine.

Is somebody having the same problem?

0 Likes