publish_bytes.py 345 B

123456789101112131415161718
  1. import asyncio
  2. from nats.aio.client import Client as NATS
  3. async def example():
  4. # [begin publish_bytes]
  5. nc = NATS()
  6. await nc.connect(servers=["nats://demo.nats.io:4222"])
  7. await nc.publish("updates", b'All is Well')
  8. # [end publish_bytes]
  9. await nc.close()
  10. loop = asyncio.get_event_loop()
  11. loop.run_until_complete(example())