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 #113

Open
sacOO7 opened this issue Jun 14, 2017 · 5 comments
Open

onDisconnect/onError not called #113

sacOO7 opened this issue Jun 14, 2017 · 5 comments

Comments

@sacOO7
Copy link

sacOO7 commented Jun 14, 2017

    You have made an awesome websocket client and I appreciate it, but there is a little imp. problem.

I think most of the people must have opened this type of issue. Whenever I shut down my wifi and internet is not available, dis-connect event is not getting fired. This is really a serious issue and must be solved. It's the primiary basic feature provided by socket and must call disconnect event when network goes off. The issue is not just in android but also in simple cmd APIs.
I think it works perfectly in OkHTTP, Then it should also be supported in this library.

@sacOO7
Copy link
Author

sacOO7 commented Jun 14, 2017

This is really necessary. I know you can do it, need just little change in the code. Other options you suggested earlier just doesn't work on any platform. They are just temporary solutions.

@TakahikoKawasaki
Copy link
Owner

Please point to the source code in OkHttp which detects disconnection of WiFi. I want to know how OkHttp achieves it. Also, please send me a pull request containing the little change that you think can detect disconnection of WiFi.

@sacOO7
Copy link
Author

sacOO7 commented Jun 22, 2017

Hey, I think it doesn't work in OkHTTP also. It's old socket problem, even in raw java sockets. Can it be effectively handled by using ping- pong mechanism? I think max delay of 2 sec should be allowed to detect socket disconnection? Can you show me the effective code to implement it?

@TakahikoKawasaki
Copy link
Owner

@sacOO7

// Get a WebSocket instance from somewhere.
WebSocket ws = ...;

// Send a ping per 2 seconds.
ws.setPingInterval(2 * 1000);

Please read "Send Ping/Pong Frames Periodically" in README.md.

@stoefln
Copy link

stoefln commented Aug 29, 2017

I noticed that onDisconnect is also not called in case the websocket server goes offline (switched off). Is this normal? Do I need to use pings? (A little bit more information on the purpose of Pings and Pongs would be cool!)
Thanks for this awesome library!

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

3 participants