facebookincubator / SocketRocket

A conforming Objective-C WebSocket client library.
Other
9.56k stars 2.01k forks source link

Force close if input and output packet loss is 100% #562

Open ezaji opened 6 years ago

ezaji commented 6 years ago

If I disable network I will be notified by - (void)webSocket:(SRWebSocket )webSocket didFailWithError:(NSError )error and socket will be closed.

But if network interface is enabled and all packets are lost I won't be notified and socket won't be closed. I use ping-pong mechanism to know that socket is alive and all packets is sent. And when ping-pong fails three times I try to close socket. But socket is never closed and readyState is always SR_CLOSING. And one more thing is that I can't just release SRWebSocket instance because one retains itself before it will be closed. How can I force close or release instance and clean all resources to prevent memory leak?

You can simulate bad network by choosing 100% Loss preset in Network Link Conditioner.

lisacmer commented 1 year ago

Did you manage to work around the issue?

I managed to fix it using [self.socket performSelector:@selector(_failWithError:) withObject:error]; It would be nice to have a better option.