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

When does the socket stop to try to emit a message when connection is lost? #322

Open
AljoSt opened this issue Jun 29, 2016 · 8 comments
Open

Comments

@AljoSt
Copy link

AljoSt commented Jun 29, 2016

Hi, I couldn't find an answer to this in the docs.
So when I switch off internet on my phone, emit a message and then turn internet back on (after a couple of seconds), the message is sent to the server. If I switch it off and wait longer before turining it back on, the message is not emitted. So does some event (Socket.EVENT_CONNECTION_ERROR, Socket_EVENT_DISCONNECT, ...) mean that retrying to emit the message is stopped?

@PatrickSR
Copy link

I think SocketIO not implemented re emit function because I have found the same problem,an than I implemented a message buffer to handle re emit when SocketIO reconnect by self.

@AljoSt
Copy link
Author

AljoSt commented Jun 29, 2016

As I said, the socket apparently does reemit. When I call socket.emit while there is no connection to the internet and then turn the wifi on after some seconds, the message is sent to the server

@PatrickSR
Copy link

I think appear re-emit only in a few seconds when socketio reconnect,if no connection too long(more than one minute),will not happen. I have tried it so I manually handle it ensure message can be re-emit.

@AljoSt
Copy link
Author

AljoSt commented Jun 29, 2016

Yeah, the question is, how can I kow that the re-emit won't be executed anymore, so that I can shedule it manually again? "More than one minute" is not exact enough ;) (or is it??) I would think that re-emitting stops when the first EVENT_CONNECTION_ERROR or EVENT_DISSCONNECT occurs, but I can't find sth that assures that. Another solution would be to cancel an emit, but I also don't know if that's possible..

@PatrickSR
Copy link

You right, these all my guess so expression is not exact enough.
Currently there is no API to control re-emit.I just consider how to avoid triggers socketio re-emit.

@AljoSt
Copy link
Author

AljoSt commented Jul 1, 2016

From what I see here: https://github.com/socketio/socket.io-client-java/blob/master/src/main/java/io/socket/client/Socket.java#L391 apparently it always tries to reemit? I tried again and even after 4 minutes of connection loss, it reemits. Apparently I made a mistake before.

@ghost
Copy link

ghost commented Mar 4, 2019

hey mate, even though this issue is already older I am facing the exact problem in javascript instead of Java. It sometimes reemits the messages as soon as the connection is back online and it sometimes doesn't, or just a part of all the emits during that time. Did you figure something out in the mean time? Or did you stop working with socket io?

@AljoSt
Copy link
Author

AljoSt commented Mar 4, 2019

Sorry, I discontinued the project before I managed to find a fix. What you could do, is to handle the (re-)sending process yourself. And in order not to process duplicate messages on the server (in case socketIO does resend a message after an interrupted connection), you could include a timestamp and an expiry date in the message.
Don't know if that helps. good luck :)

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

No branches or pull requests

3 participants