NativeWebSocket
NativeWebSocket copied to clipboard
App Freezing when internet is turned off but still device is connected to wi-fi network
Our app use-case contains where we are dispatching messages on Web socket every X seconds.
If we disconnect the app from internet (Using a mobile hotspot and turning off the internet source without turning off the mobile hotspot), then app is freezing after sometime.
Our observation from logs:
- When internet connection is turned off, Websocket state is still being returned as Open, instead of Closed
- So, the messages are still trying to be dispatched on Websocket and after sometime, the task at this line is causing app freeze - https://github.com/endel/NativeWebSocket/blob/60b2960bef354ba9886af15a9a83a6e61164240b/NativeWebSocket/Assets/WebSocket/WebSocket.cs#L569
Please let me know how to overcome this issue.
I have published a pull request that fixes this exact issue. You can try that FixedApplicationFreezeIssueOnInternetDisconnect #90