socketio / socket.io-client-java

Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.
https://socketio.github.io/socket.io-client-java/installation.html
Other
5.31k stars 969 forks source link

How the retry/reconnect life cycle works on the newest version #721

Open Canato opened 1 year ago

Canato commented 1 year ago

Good day! First, thanks for this unique library and maintained repository we have here. I hope my questions don't sound silly and found the team in a great start of the week.

Context 🗒️

Using the library today in our Android project (kotlin code), we found ourselves in the moment of providing the user with some UI layout while trying to reconnect.

Lifecycle

Checking the library documentation the state machine raises a question for me

  1. We try to reconnect only after a successful connection? So if it fails on the first attend, won't it reconnect?

Lifecycle - Event names

Is there a way to know which events will happen during the reconnection state? Socket class has 3 reserved events: connect, disconnect and connect_error But I was looking for something with more details.

On the documentation, we have:

socket.io.on("reconnection_attempt", () => { ... });
socket.io.on("reconnect", () => { ... });

But on the Manager class, I can only find reconnect_attempt instead of reconnection just wanna double sure these are the correct ones.

  1. Can we know the event sequence?, like: open > connect_error > reconnection_attempt > reconnect_error > reconnection_attempt > reconnect > connect

Manual test

What would be your suggestion for us the test the reconnection state in Android? I would like to try to connect, and it fails, so I would try x times before disconnecting.

Thanks!