reconnect_no_random.py 495 B

123456789101112131415161718192021222324
  1. import asyncio
  2. from nats.aio.client import Client as NATS
  3. async def example():
  4. # [begin reconnect_no_random]
  5. nc = NATS()
  6. await nc.connect(
  7. servers=[
  8. "nats://demo.nats.io:1222",
  9. "nats://demo.nats.io:1223",
  10. "nats://demo.nats.io:1224"
  11. ],
  12. dont_randomize=True,
  13. )
  14. # Do something with the connection
  15. await nc.close()
  16. # [end reconnect_no_random]
  17. loop = asyncio.get_event_loop()
  18. loop.run_until_complete(example())
  19. loop.close()