recws-org / recws

Reconnecting WebSocket is a websocket client based on gorilla/websocket that will automatically reconnect if the connection is dropped and keeps the connection alive - thread safe!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeepAliveTimeout option causes multiple connections to be created and orphaned

jotto opened this issue · comments

If you're blocking on ReadMessage(), while the goroutine for KeepAliveTimeout fires a closeAndReconnect, the ReadMessage will fire a second closeAndReconnect. This causes more and more connections to be created and orphaned.

commented

The root cause of the bug is simultaneous running of the connect goroutines.
Please take a look at #34 - should be fixed there.

The issue is still present

Please look my pr #56

Here problem in twice call go connect()

  • first from method keepAlive(), the timer channel waiting can call any time, because of this close() method doesn't work, if use keepAlive()
  • second from any place there have call CloseAndReconnect() method