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

Better approach #57

Open
0x366 opened this issue Apr 26, 2023 · 0 comments
Open

Better approach #57

0x366 opened this issue Apr 26, 2023 · 0 comments

Comments

@0x366
Copy link

0x366 commented Apr 26, 2023

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.

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