nc, err := nats.Connect("demo.nats.io")
if err != nil {
log.Fatal(err)
}
defer nc.Close()
mp := nc.MaxPayload()
log.Printf("Maximum payload is %v bytes", mp)
// Do something with the max payload
Connection nc = Nats.connect("nats://demo.nats.io:4222");
long max = nc.getMaxPayload();
// Do something with the max payload
nc.close();
let nc = NATS.connect("nats://demo.nats.io:4222");
// on node you *must* register an error listener. If not registered
// the library emits an 'error' event, the node process will exit.
nc.on('error', (err) => {
t.log('client got an error:', err);
});
nc.on('connect', () => {
t.log(nc.info.max_payload);
});
nc = NATS()
await nc.connect(servers=["nats://demo.nats.io:4222"])
print("Maximum payload is %d bytes" % nc.max_payload)
# Do something with the max payload.
require 'nats/client'
NATS.start(max_outstanding_pings: 5) do |nc|
nc.on_reconnect do
puts "Got reconnected to #{nc.connected_server}"
end
nc.on_disconnect do |reason|
puts "Got disconnected! #{reason}"
end
# Do something with the max_payload
puts "Maximum Payload is #{nc.server_info[:max_payload]} bytes"
end
// connect will happen once - the first connect
nc.on('connect', (nc: Client, url: string, options: ServerInfo) => {
// nc is the connection that connected
t.log('client connected to', url);
t.log('max_payload', options.max_payload);
});