This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Object - nats : Connection

Represents a single network connection to the NATS server.



(string[] url, ConnectionConfig? config)

  • url string[] [DEFAULT_URL]
  • The NATS Broker URL. For a clustered use case, pass the URLs as a string array

  • config ConnectionConfig? ()
  • Configurations associated with the NATS client to establish a connection with the server


Closes a given connection.


(boolean forceful)

returns Error?

Closes a given connection.


  • forceful boolean (default false)
  • The graceful shutdown flag. If true, the connection closes immediately. The default value is false.

  • Return Type

  • () or else a nats:Error if unable to complete the close operation.