Monitoring the Connection
For example, the client library may provide a mechanism to get the connection’s current status:
Java
System.out.println("The Connection is: " + nc.getStatus());
nc.close();
System.out.println("The Connection is: " + nc.getStatus());
Python
nc = NATS()
)
# Do something with the connection.
print("The connection is connected?", nc.is_connected)
while True:
if nc.is_reconnecting:
await asyncio.sleep(1)
await nc.close()
print("The connection is closed?", nc.is_closed)
TypeScript
if(nc.isClosed()) {
t.log('the client is closed');
} else {