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

Library reconnects only once #7

Closed
pvanderlinden opened this issue Jan 30, 2018 · 3 comments
Closed

Library reconnects only once #7

pvanderlinden opened this issue Jan 30, 2018 · 3 comments

Comments

@pvanderlinden
Copy link
Contributor

I can not get reconnects working, I have tested it with a program publishing and consuming, if I shut down the server for a few seconds, they both will stop working (the publisher will timeout on publishing, the consumer will just not receive any messages anymore)

Connection code:

from functools import partial


async def test_cb(cb_type, *args, **kwargs):
    print(cb_type, args, kwargs)

nc = NATS()
await nc.connect(io_loop=loop, error_cb=partial(test_cb, 'error'), disconnected_cb=partial(test_cb, 'disconnect'), closed_cb=partial(test_cb, 'closed'), reconnected_cb=partial(test_cb, 'reconnect'), ping_interval=25)

Output:

error (NatsError('nats: empty response from server when expecting INFO message',),) {}
reconnect () {}
error (<class 'nats.aio.errors.ErrStaleConnection'>,) {}
disconnect () {}
error (NatsError('nats: empty response from server when expecting INFO message',),) {}
error (ConnectionRefusedError(111, "Connect call failed ('127.0.0.1', 4222)"),) {}
disconnect () {}
closed () {}

What I understand from the defaults it should try to reconnect 10 times with a delay of 2 seconds, which means if the server is down for less then 20 seconds it should at least reconnect and resume operation, unfortunately it won't resume operation (the consumer will just not receive anything anymore, the producer will timeout on a publish call, even when the server is back up again).

@wallyqs
Copy link
Member

wallyqs commented Jan 30, 2018

Thanks for the report, I'll take a look at it today.

@pvanderlinden
Copy link
Contributor Author

Is there a cause known? Is this maybe actually a bug for the base NATS?

@wallyqs
Copy link
Member

wallyqs commented Feb 10, 2018

Yes, this looks like to be an issue from the underlying nats client https://github.com/nats-io/asyncio-nats need to revise the reconnection logic against already failed servers and update.

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

2 participants