-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Reconnect #415
Comments
It seems to me that I understood the essence of the problem: If there is no internet connection and we send a request via webSocket, we do not receive any notifications. Also, if a request was sent without the Internet to the server (1), then another, separate object will not send a request to the server (2), because it will be occupied by the server (1). I tried on different threads and nothing happens: ( |
I rolled back to version 2.1.1 and everything works fine. Please correct in the new update. |
I'm not sure what you are seeing and thus I can't correct it. There have been a lot of changes from 2.1.1 to the latest version, but all the versions have passed the Autobahn tests as expected. |
The code is simple: socket.onDisconnect = {[weak self] (error: error?) in { In version 2.1.1, when calling self.socket.connect () in the socket.onDisconnect = {block: error?} In {}, if there is no connection, the socket.onDisconnect = {is returned again. {{Error: error?} { }, as in the example above. It works cyclically as it should work.In versions> 3 block socket.onDisconnect = {(error: error?) In {} it is called once, despite the fact that it contains self.socket.connect () and there is no connection to the server. And if a code call is higher and a connection is made to another socket on another server, then the other connector will not connect. It seems that the first socket does not do this and the second one can not complete the connection. |
I did a bit of digging in this. The issue is the underlining socket isn't ready for reuse when you call connect again. The foundation stream object never becomes "ready" (hasSpaceAvaliable is never updated to true). This create a cycle of attempting to reconnect and the socket never being ready. I generally would avoid calling P.S. 3.0.4 was also just released with some better disconnect logic. |
What things should we check before calling |
Hey. Tell me please, can I do reconnect this way:
socket.onDisconnect = { (error: error?) in {
self.socket.connect ()
}
At such attempt I have errors in the console and when I call connect () I do not get into onDisconnect {} any more. :( The main thing is that on swift 3 this method worked.
I ask you to give advice on how to improve my code. Thank you in advance for your cooperation.
The text was updated successfully, but these errors were encountered: