opts := nats.GetDefaultOptions()
opts.Url = "demo.nats.io"
// Turn on Verbose
opts.Verbose = true
nc, err := opts.Connect()
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connection
Options options = new Options.Builder().
server("nats://demo.nats.io:4222").
verbose(). // Turn on verbose
build();
Connection nc = Nats.connect(options);
// Do something with the connection
nc.close();
let nc = NATS.connect({
url: "nats://demo.nats.io:4222",
verbose: true
});
nc = NATS()
await nc.connect(servers=["nats://demo.nats.io:4222"], verbose=True)
# Do something with the connection.
require 'nats/client'
NATS.start(verbose: true) do |nc|
nc.on_reconnect do
puts "Got reconnected to #{nc.connected_server}"
end
nc.on_disconnect do |reason|
puts "Got disconnected! #{reason}"
end
nc.close
end
// will throw an exception if connection fails
let nc = await connect({
url: "nats://demo.nats.io:4222",
verbose: true
});
nc.close();