-
Notifications
You must be signed in to change notification settings - Fork 36
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
Reconnecting to server after failure #20
Comments
Hi, do you know how to compile the library yourself? In this line |
Actually, I have never built a library like this. |
I looked into it. I pointed you at the wrong file. The right files are WebsocketClient.java and WebsocketClientEvents.java. In the second file, find @OnWebSocketError. When that happens it should call a method on the first file. Both files have two Method. I would add a third one for errors to then call a user function on errors. That's one option. Another option is to just have a public property indicating if the connection is active or not. To compile the library you can open the project (the .iml file) using IntelliJ Idea, then run Build > Generate Artifacts which will put the new jar file into this folder: Unfortunately no time to work on this now. |
A fancier version would deal with reconnecting automatically inside the library, and either cue or discard messages when trying to send them while the connection is down (currently it will throw an exception and terminate). |
Thanks @hamoid. That's very useful advice. I'll try to give it a crack in the weekend. |
I've tried to implement the first suggestion here: I had to change a few things, and now a Any ideas? |
I have sort of resolved this by doing a This is really hacky though. I think proper exception handling is lacking at various levels. |
Hey @botherder , thanks a lot for your fork! As you mentioned, I'm calling sendMessage() periodically to see if it fails. Just creating a new WebsocketClient when this happens is not a working solution, as the resources from the client are not freed and the used RAM keeps increasing until crash happens. |
In order to make a failproof installation, I need to make sure that a WebsocketClient connection can be re-established after a temporary failure from the server. While I can just periodically enforce e reconnection regardless, it would be useful to be able to monitor for events or check the connection status of the client. Is there any way you suggest to do this?
Thanks for your work.
The text was updated successfully, but these errors were encountered: