Skip to content
Elixir client for NATS, the cloud native messaging system.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

NATS - Elixir Client

A Elixir client for the NATS messaging system.

License MIT Build Status Inline docs

Here is a sample configuration to connect to your NATS server.

# In your config/config.exs file
config :nats, Nats.Connection,
  url: "",
  port: 4222,
  verbose: true,
  pedantic: false,
  user: "aforward",
  password: "nicetry",
  tcp: [:binary, active: false],

To play around with the client, start your NATS server, for example (using docker)

docker run -it -p 4222:4222 -p 6222:6222 -p 8222:8222 --name=nats nats:0.6.6

The output should look similar to

[1] 2015/09/07 21:49:00.431970 [INF] Starting gnatsd version 0.6.6
[1] 2015/09/07 21:49:00.432082 [INF] Starting http monitor on port 8222
[1] 2015/09/07 21:49:00.432191 [INF] Listening for route connections on :6222
[1] 2015/09/07 21:49:00.432285 [INF] Listening for client connections on
[1] 2015/09/07 21:49:00.432356 [INF] gnatsd is ready

Now start your iex from the elixir-nats directory

iex -S mix

You should see your nats server properly connected (make sure to get the configs right above)

[info] Attempting to connect to NATS Server:
[info] Connected.

Now you can send messages to the server


I am still figuring out the protocol, so the only way to see that the connection was actually established was to send an invalid message and watch the NATS server report the error


Which would report an error similar to

[1] 2015/09/07 21:51:45.962684 [ERR] - cid:1 - Error reading from client: Client Parser ERROR, state=0, i=0: proto='"GARBLE\r"...'

Next steps are to figure out protocol and wrap in meaningful helper functions.

You can’t perform that action at this time.