// Set a user and plain text password
nc, err := nats.Connect("myname:password@127.0.0.1")
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connection
Connection nc = Nats.connect("nats://myname:password@localhost:4222");
// Do something with the connection
nc.close();
let url = `nats://myname:password@127.0.0.1:${port}`;
let nc = NATS.connect(url);
nc = NATS()
await nc.connect(servers=["nats://myname:password@demo.nats.io:4222"])
# Do something with the connection.
require 'nats/client'
NATS.start(servers:["nats://myname:password@127.0.0.1:4222"], name: "my-connection") do |nc|
nc.on_error do |e|
puts "Error: #{e}"
end
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
let url = `nats://myname:password@127.0.0.1:${port}`;
let nc = await connect({url: url});