Connecting to the Default Server
Go
Connection nc = Nats.connect();
// Do something with the connection
nc.close();
JavaScript
nc = NATS()
await nc.connect()
await nc.close()
Ruby
// will throw an exception if connection fails
let nc = await connect();
// Do something with the connection
// When done close it
nc.close();
// alternatively, you can use the Promise pattern
let nc1: Client;
connect()
.then((c) => {
nc1 = c;
// Do something with the connection
nc1.close();
// add a .catch/.finally
C