Skip to content

Auto reconnect #9

@sealedtx

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

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