Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onDisconnect/onError not called #13

Open
nagamanojv opened this issue Jun 15, 2017 · 9 comments
Open

onDisconnect/onError not called #13

nagamanojv opened this issue Jun 15, 2017 · 9 comments

Comments

@nagamanojv
Copy link

Hi @sacOO7 , I am currently facing the exact issue you reported with neovisionaries. I am using it in Android phones majority of which are on 2G sims. Several times it happens that android doesn't identify the connection is broken(2G symbol available) but the connection with server is broken. It never identifies the connection is broken and never initiates the reconnection loop until the phone is rebooted or the internet connection is gone completely.

Is there any work around at the moment.?

@sacOO7
Copy link
Owner

sacOO7 commented Jun 22, 2017

You can use the onnetwork connectivity change listener to detect internet connectivity. I would recommend using library https://github.com/zplesac/android_connectionbuddy, if you want to save time.

@nagamanojv
Copy link
Author

Hi @sacOO7 I tried that library but it has the same problem it seems. It checks if network status change (from connected to disconnect or vice versa) but when connectivity changes when network status not changed (connected to hotspot which inturn lost connection).

@sacOO7
Copy link
Owner

sacOO7 commented Jun 27, 2017

I think I have to check for PING frames while receiving data, I will try to add some solution today regarding issue. Remind me of this issue in case I forget to do it. Thanks for your time.

@nagamanojv
Copy link
Author

Hi @sacOO7 will you be doing that ping frames related change soon.! I am kind of blocked on it for now.

@sacOO7
Copy link
Owner

sacOO7 commented Jun 29, 2017 via email

@nagamanojv
Copy link
Author

Hi @sacOO7 when I set
ws.setPingInterval(5000);
in Socket.java in connect() method, it seems to be working. i.e application is identifying disconnection immediately in the case we discussed earlier. Is it the change you were planning to make or there is something else should be done.

Really sorry to go after you on this but this is a bit critical for me.

@sacOO7
Copy link
Owner

sacOO7 commented Jun 30, 2017

It seems you were able to access raw websocket instance. Yes, you are right !!! I was talking about same solution for identifying disconnection. I might have to add that code internally. But as you can see, you can actually have instance and perform required operations on it :)

@nagamanojv
Copy link
Author

I did it in your code only :) Forked it, checked out, made changes and tried. It worked.

I am just worried about the effect on data usage because of this change. What would be the ideal interval for ping (given that the value is 8 seconds at the server, though that is configurable). I know the ideal interval is dependent on how quickly I need to identify but as I said I also have limitation on the data the app use. If the ping frames consume too much data, then I will have to compromise on the frequency.

@sacOO7
Copy link
Owner

sacOO7 commented Jun 30, 2017

There won't be a lot of consumption in the data. You don't have to worry about it. It's in some bytes sent after some interval. Even for 1KB it will take 2 minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants