connect_options.py 332 B

1234567891011121314151617
  1. import asyncio
  2. from nats.aio.client import Client as NATS
  3. async def example():
  4. # [begin connect_options]
  5. nc = NATS()
  6. await nc.connect(connect_timeout=2)
  7. # Do something with the connection
  8. await nc.close()
  9. # [end connect_options]
  10. loop = asyncio.get_event_loop()
  11. loop.run_until_complete(example())
  12. loop.close()