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

Auto reconnect #9

Open
sealedtx opened this issue Oct 9, 2019 · 1 comment
Open

Auto reconnect #9

sealedtx opened this issue Oct 9, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@sealedtx
Copy link

sealedtx commented Oct 9, 2019

Hi, thank you for the nats-python.
It would be great if there will be an option to set auto reconnect to server.
I have found solution to detect disconnects when publish:
`

def publish(self, subject, data):
    try:
        self._nats.publish(subject, payload=bytes(json.dumps(data), encoding='utf-8'))
    except BrokenPipeError:
        while True:
            try:
                self._nats.reconnect()
                self.publish(subject, data)
                break
            except:
                pass

`

But I don't know how to detect disconnects when subscribe, program just freezes

@Gr1N
Copy link
Owner

Gr1N commented Oct 13, 2019

Hi and thanks, glad that nats-python solves your problems!

About reconnects. Yes, this is a known problem (you can find a similar issue and a proposal to solve it at #5) and honestly, I don't know how to solve it in the right way. We need somehow understand is socket healthy or not. I don't have free time for now to deep dive into, but if you want to spend some time and find a solution it would be great. PR is always welcome.

@Gr1N Gr1N added the bug Something isn't working label Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants