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

lost connection inconstencies? #78

Open
nathanday opened this issue Dec 15, 2017 · 1 comment
Open

lost connection inconstencies? #78

nathanday opened this issue Dec 15, 2017 · 1 comment

Comments

@nathanday
Copy link

Trying to handle a loss of network connection in our app I have found inconsistencies when trying to reconnect. The two ways I test loss of network are, using Apples "Network Link Conditioner" with 100% loss and pulling out the Ethernet cable. When my error delegate method (websocketDidDisconnect:error:) is called I just wait a small amount of time and call connect again on the same JFRWebSocket instance, I also call writePing: periodically when I have a connection to test its still connected. If the connection is broken by Network Link Conditioner, my error delegate method is called every time I try to reconnect until the network is restored and I can connect. But if I pull out the Ethernet cable, my error delegate method is called when the connection is broken, but when I try reconnecting again my error delegate is never called so there is no way for me to know the re-connection attempt failed and I should wait a bit and try again. I guess the second behaviour based on the method name websocketDidDisconnect:error: make senses, but then there isn't a way to an attempt to connect failed.
Is reusing the same JFRWebSocket after network loss OK or should I create a new instance all together? Maybe I should be calling disconnect on JFRWebSocket before I try reconnect? Maybe I have discovered a bug?
Thanks

@nathanday
Copy link
Author

nathanday commented Jan 3, 2018

I have had a chance to look at this myself, the problem is a race condition with the instances variable didDisconnect, if you try to connect and it fails immediately, the method -[JFRWebSocket doDisconnect:] is called before the block to set self.didDisconnect = NO in -[JFRWebSocket connect] is called. Is setting self.didDisconnect in a queue for key value observing? If so the testing of self.didDisconnecting should occur in the queue as well.
I would provide the fix for this myself, but where I work I'm behind a very strict fire wall.

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

1 participant