opts := nats.GetDefaultOptions()
opts.Url = "demo.nats.io"
// Set maximum number of PINGs out without getting a PONG back
// before the connection will be disconnected as a stale connection.
opts.MaxPingsOut = 5

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").
                            maxPingsOut(5). // Set max pings in flight
                            build();
Connection nc = Nats.connect(options);

// Do something with the connection

nc.close();
let nc = NATS.connect({
    maxPingOut: 5,
    url: "nats://demo.nats.io:4222"
});
nc = NATS()

await nc.connect(
   servers=["nats://demo.nats.io:4222"],
   # Set maximum number of PINGs out without getting a PONG back
   # before the connection will be disconnected as a stale connection.
   max_outstanding_pings=5,
   ping_interval=1,
   )

# Do something with the connection.

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 connection
end
// will throw an exception if connection fails
let nc = await connect({
    maxPingOut: 5,
    url: "nats://demo.nats.io:4222"
});
nc.close();