nats-io / stan.py

Python Asyncio NATS Streaming Client
https://nats.io
Apache License 2.0
113 stars 23 forks source link

Reconnection problem after server reboot #51

Open chermed opened 3 years ago

chermed commented 3 years ago

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 ?

resulyrt93 commented 3 years ago

Is there any solution about that issue?

chermed commented 2 years ago

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