Skip to content

[Errno 107] Transport endpoint is not connected #28

Description

@gborrageiro

Hello,

When trying to post messages to a nats server, I am getting regular errors of the form:

[Errno 107] Transport endpoint is not connected

I set up the connection as follows:

self.nats_client = NATSClient(
            url=self.nats_url, socket_timeout=60., socket_keepalive=True, verbose=True
        )
        self.nats_client.connect()

After I receive the error, I try setting up the connection again:

        try:
            self.nats_client.publish(
                subject=self.nats_subject,
                payload=json.dumps(
                    self.nats_msg, indent=2
                ).encode('utf-8')
            )
        except Exception as e:
            self.nats_client.close()
            self.nats_client.connect()

Am I expected to run self.nats_client.connect() each time before I try publish? There is a performance cost for doing so, which is why I have tried to avoid doing it regularly.

Thanks
Gabriel

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions