Skip to content

Auto reconnect #9

Open
Open

Description

@sealedtx

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

Activity

  1. Gr1N commented on Oct 13, 2019

    @Gr1N
    Owner

    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.

  2. added
    bugSomething isn't working
    on Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions