recws icon indicating copy to clipboard operation
recws copied to clipboard

Better approach

Open 0x366 opened this issue 2 years ago • 1 comments

Was playing around with this lib trying to have a fault tolerant ws connection. Tried patches from different prs and forks, still there was a present problem with race - multiple reconnects occurring from time to time. Also making a custom heartbeat is a headache.

And realised, why not just wrap the ws listener in infinite cycle?

	for {
		select {
		case <-ctx.Done():
			return
		default:
			err := InitAndListenWs()
			if err != nil {
				....
			}
		}
	}

No concurrency problems and easy to implement.

0x366 avatar Apr 26 '23 10:04 0x366

Please see #61

loeffel-io avatar Dec 04 '24 10:12 loeffel-io