Nats-py

Latest version: v2.9.0

Safety actively analyzes 702367 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 5 of 6

0.8.2

Added

- Support using tls scheme to setup default context to connect securely (https://github.com/nats-io/asyncio-nats/pull/88)

python
await nc.connect("tls://demo.nats.io:4443")
await nc.connect(servers=["tls://demo.nats.io:4443"])


Example using `nats-pub` & `nats-sub`:


$ python3.7 examples/nats-pub -s tls://demo.nats.io:4443 hello -d world
...

$ python3.7 examples/nats-sub -s tls://demo.nats.io:4443 hello
Connected to NATS at demo.nats.io:4443...
Received a message on 'hello ': world


If using Python 3.7 in OS X and getting SSL errors, run first the following to install the `certifi` default certs:


/Applications/Python\ 3.7/Install\ Certificates.command

0.8.0

Added

- Support for `drain mode` (https://github.com/nats-io/asyncio-nats/pull/82)

This feature allows clients to gracefully disconect, letting the subscribers
handle any inflight messages that may have been sent by the server already.

python
async def handler(msg):
print("[Received] ", msg)
await nc.publish(msg.reply, b'I can help')

Can check whether client is in draining state
if nc.is_draining:
print("Connection is draining")

await nc.subscribe("help", "workers", cb=handler)

requests = []
for i in range(0, 1000):
request = nc.request("help", b'help!', 0.2)
requests.append(request)

Wait for all the responses
responses = await asyncio.gather(*requests)
print("Received {} responses", len(responses))

Gracefully close the connection.
await nc.drain()


Example usage can be found at:
https://github.com/nats-io/asyncio-nats/blob/e1996e7c4ae30daa63c49af20700d42fad1bd2f2/examples/drain-sub.py

- Support for `no_echo` mode (https://github.com/nats-io/asyncio-nats/pull/74)

When connected to a NATS Server v1.2.0 or above, a client can now opt to avoid
receiving messages that it itself has published.

python
await ncA.connect(no_echo=True)
await ncB.connect()

async def handler(msg):
Messages sent by `ncA' will not be received.
print("[Received] ", msg)

await ncA.subscribe("greetings", cb=handler)
await ncA.publish("greetings", b'Hello World!')
await ncB.publish("greetings", b'Hello World!')


- Added `connect_timeout` option to disconnect from unhealthy servers in the pool (https://github.com/nats-io/asyncio-nats/pull/83/files)

python
Give up if can't connect to a server in 5 seconds
await nc.connect("demo.nats.io:4222", connect_timeout=5)


- Added `loop` parameter to connect to set the event loop like in `asyncio` APIs

python
await nc.connect("demo.nats.io", loop=asyncio.new_event_loop())


Improved

- `connect` API is now modeled to work more closely to how the Go client works:

python
Assume 'nats://' scheme
await nc.connect("demo.nats.io:4222")

Complete with scheme a la Go client classic usage.
await nc.connect("nats://demo.nats.io:4222")

Use default 4222 port.
await nc.connect("demo.nats.io")

Explicit cluster list
await nc.connect(servers="demo.nats.io")


Fixed

- Examples and tests now support Python 3.7 (https://github.com/nats-io/asyncio-nats/issues/71)

- Added `user`, `password`, `token` parameters to set the auth credentials for servers that were discovered implicitly. (https://github.com/nats-io/asyncio-nats/commit/f8c28b346fd5fbc852b7e046edf0ef4810cdf823)

python
Set user and info credentials
await nc.connect("127.0.0.1:4222", user="foo", password="bar")

Token
await nc.connect("127.0.0.1:4222", token="secretoken")


Changed

- Examples were changed to use `async`/ `await` instead of `asyncio.coroutine` and `yield from` (https://github.com/nats-io/asyncio-nats/commit/e1996e7c4ae30daa63c49af20700d42fad1bd2f2)

Deprecated

- Removed Python 3.4 from build (https://github.com/nats-io/asyncio-nats/commit/b2ee929367d3bf6b06bed0ab32e3a9f27b041747)

- Tests are now using `async`/`await` syntax throughout (https://github.com/nats-io/asyncio-nats/pull/78)
In the next v1.0 release client will be solely using `async`/`await` syntax (https://github.com/nats-io/asyncio-nats/issues/68)

0.7.2

Fixed

- Improve behavior of reconnection logic (https://github.com/nats-io/asyncio-nats/pull/67)

- Issue with tasks left pending after calling `close()` (https://github.com/nats-io/asyncio-nats/pull/69)

0.7.0

Added

- New style request/response implementation (https://github.com/nats-io/asyncio-nats/pull/59)

- The `ErrSlowConsumer` now include `sid` and `subject` when a message is dropped (https://github.com/nats-io/asyncio-nats/pull/58)

- New options `pending_msgs_limit` and `pending_bytes_limit` were added to `subscribe` API
for controlling limits of pending data waiting to be processed before dropping messages.
(https://github.com/nats-io/asyncio-nats/pull/58)

- `Msg` type now uses `__slots__` (https://github.com/nats-io/asyncio-nats/pull/58)

Improved

- More performant inbox generation via `NUID` approach (https://github.com/nats-io/asyncio-nats/pull/57)

Fixed

- Each `Subscription` now has a task so coroutines no longer
cause head of line blocking to each other.
(https://github.com/nats-io/asyncio-nats/pull/58)

Changed

- `request` API when a callback is not passed now blocks and waits for response
using the new style request/response API which is less chatty over
the network.
(https://github.com/nats-io/asyncio-nats/pull/59)

Deprecated

- `subscribe_async` will be deprecated in next release,
as a workaround a task can be created inside of a handler and would
result in more control than can have in the library.

0.6.4

Fixed

- Fix to issue of connection being closed when upgrading to TLS (https://github.com/nats-io/asyncio-nats/pull/49)
- Fix to cancel pending reconnection task when closing connection (https://github.com/nats-io/asyncio-nats/pull/50)

0.6.2

Fixed

- Fix `allow_reconnect` to bail connecting on errors during after first connect (https://github.com/nats-io/asyncio-nats/pull/48)
- Fix error handling when server does not respond with properly formed INFO line on connect (https://github.com/nats-io/asyncio-nats/pull/47 , https://github.com/nats-io/asyncio-nats/pull/44)
- Fix checks for keys in INFO line and use defaults if not present (https://github.com/nats-io/asyncio-nats/pull/48)

Page 5 of 6

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.