Observed behavior
There is an issue which seems to be related to #490 but maybe not the same. Imagine connecting to a server which has TLS configured but you're providing the wrong certificate. The client will get stuck in a never-terminating state, not trying to re-connect but also not trying to exec.
To recreate, configure a server with TLS, and then simply connect (reconnect is here for clarification, its actually the default.
import asyncio
import nats
async def main():
# It is very likely that the demo server will see traffic from clients other than yours.
# To avoid this, start your own locally and modify the example to use it.
await nats.connect("nats://localhost:4222", allow_reconnect=True)
if __name__ == "__main__":
asyncio.run(main())
After throwing the SSL error (ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate), which is totally expected, the client hangs infinitely. I debugged the code and traced it to the transport handling.
The _close() method is called, which works fine until this part:
|
if self._transport is not None: |
|
self._transport.close() |
|
try: |
|
await self._transport.wait_closed() |
|
except Exception as e: |
|
await self._error_cb(e) |
The code never reaches anything after that block, it enters wait_closed in line 784 and gets stuck in there indefinitely.
Expected behavior
It should stop gracefully if the connection fails.
Server and client version
- Client:
2.11.0
- Server: latest docker tag
Host environment
MacOS, although I doubt it matters.
Steps to reproduce
See above
Observed behavior
There is an issue which seems to be related to #490 but maybe not the same. Imagine connecting to a server which has TLS configured but you're providing the wrong certificate. The client will get stuck in a never-terminating state, not trying to re-connect but also not trying to exec.
To recreate, configure a server with TLS, and then simply connect (
reconnectis here for clarification, its actually the default.After throwing the SSL error (
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate), which is totally expected, the client hangs infinitely. I debugged the code and traced it to the transport handling.The
_close()method is called, which works fine until this part:nats.py/nats/aio/client.py
Lines 781 to 786 in 8f53949
The code never reaches anything after that block, it enters
wait_closedin line 784 and gets stuck in there indefinitely.Expected behavior
It should stop gracefully if the connection fails.
Server and client version
2.11.0Host environment
MacOS, although I doubt it matters.
Steps to reproduce
See above