stan.py icon indicating copy to clipboard operation
stan.py copied to clipboard

Reconnection problem after server reboot

Open chermed opened this issue 3 years ago • 2 comments

My environment is :

server: nats-streaming:0.21.1-alpine
asyncio-nats-client @ asyncio-nats-client-0.11.4.tar.gz
asyncio-nats-streaming @ asyncio-nats-streaming-0.4.0.tar.gz
python 3.7

My script is :

import asyncio
from nats.aio.client import Client as NATS
from stan.aio.client import Client as STAN

async def run(loop):

    nc = NATS()
    await nc.connect(io_loop=loop, allow_reconnect=True)
    sc = STAN()
    await sc.connect("test-cluster", "client-123", nats=nc)
    async def cb(msg):
        print("(seq={}): {}".format(msg.seq, msg.data))


    sub = await sc.subscribe("hi", start_at='first', cb=cb, durable_name="dname")


if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run(loop))
    loop.run_forever()

If I restart the NATS server, the client doesn't receive anymore any message, it just show : empty response from server when expecting INFO message

I tried to force the reconnection using some connection callback but it didn't work

Do I miss something ?

chermed avatar Mar 07 '21 17:03 chermed

Is there any solution about that issue?

resulyrt93 avatar Sep 10 '21 08:09 resulyrt93

@resulyrt93 no solution found for that! Try with Jetstreams (I didn't try)

chermed avatar Sep 13 '21 11:09 chermed