Go Ruby Makefile
Clone or download
Failed to load latest commit information.
.github [ci skip] Upd readme and changelog; add Upgrade docs Mar 5, 2018
Godeps Add nanoid; add RPC stub Mar 5, 2018
cli Upd mruby metrics API; fix test command May 10, 2018
cmd/anycable-go Upd mruby metrics API; fix test command May 10, 2018
config Upd mruby metrics API; fix test command May 10, 2018
etc Upd mruby build config May 10, 2018
metrics Upd mruby metrics API; fix test command May 10, 2018
mrb Add mruby engine May 10, 2018
node Add custom printer support May 10, 2018
pool Add RPC controller Mar 5, 2018
protos Upgrade to AnyCable 0.5.0; fix connection closing Oct 21, 2017
pubsub updated redis dependency Apr 5, 2018
rpc Refactor metrics (add names and descs); add RPC metrics Mar 6, 2018
server Add Prometheus metrics HTTP exporting Mar 7, 2018
utils Add ws_handler, session and node Mar 5, 2018
vendor Add go-mruby May 10, 2018
.gitignore [Fixes #23] Fix bug when non-JSON messages broadcasted as nulls Dec 22, 2017
.travis.yml Update travis notification settings Mar 7, 2018
CHANGELOG.md [ci skip] Bump 0.6.0-preview6 May 10, 2018
DOWNLOADS.md [ci skip] v0.5.4 Feb 8, 2018
Dockerfile [ci skip] Upd Dockerfile Oct 25, 2017
Gopkg.lock Add go-mruby May 10, 2018
Gopkg.toml updated redis dependency Apr 5, 2018
MIT-LICENSE Add 0.3.0 downloads Jan 22, 2017
Makefile Upd mruby build config May 10, 2018
Readme.md [ci skip] Upd installing from source instructions Jun 13, 2018
UPGRADE.md [ci skip] Upd readme and changelog; add Upgrade docs Mar 5, 2018
dependencyci.yml Add DependencyCI config Oct 1, 2017


Build Status Dependency Status Gitter

AnyCable-Go WebSocket Server

WebSocket server for AnyCable.

NOTE: this is a readme for the upcoming 0.6.0 version. Go to 0.5.x version.


The easiest way to install AnyCable-Go is to download a pre-compiled binary.

Or with Homebrew

brew install anycable/anycable/anycable-go

Of course, you can install it from source too:

CGO_ENABLED=0 go get -u -f github.com/anycable/anycable-go/cmd/anycable-go

NOTE: right now it's not possible to build anycable-go with mruby support using the command above (that's why we added CGO_ENABLED=0). To install anycable-go with mruby from source try:

go get -d -u -f github.com/anycable/anycable-go/cmd/anycable-go && (cd $GOPATH/src/github.com/anycable/anycable-go && make prepare-mruby install)


For instructions on how to upgrade to a newer version see upgrade notes.


See heroku-anycable-go buildpack.


Run server:

anycable-go --rpc_host= --headers=cookie,x-api-token --redis_url=redis://localhost:6379/5 --redis_channel=anycable --host= --port=8080

=> INFO 2018-03-05T08:44:57.684Z context=main Starting AnyCable 0.6.0

You can also provide configuration parameters through the corresponding environment variables (i.e. ANYCABLE_RPC_HOST, ANYCABLE_REDIS_URL, etc).

For more information about available options run anycable-go -h.

Metrics & Stats

Anycable-Go provides useful statistical information about the service (such as a number of connected clients, received messages, etc.).


To enable a HTTP endpoint to serve Prometheus-compatible metrics (disabled by default) you must specify --metrics_http option (e.g. --metrics_http="/metrics").

You can also change a listening port and listening host through --metrics_port and --metrics_host options respectively (by default the same as the main (websocket) server port and host, i.e. using the same server).

The exported metrics format is the following:

# HELP anycable_go_clients_num The number of active clients
# TYPE anycable_go_clients_num gauge
anycable_go_clients_num 0

# HELP anycable_go_clients_uniq_num The number of unique clients (with respect to connection identifiers)
# TYPE anycable_go_clients_uniq_num gauge
anycable_go_clients_uniq_num 0

# HELP anycable_go_client_msg_total The total number of received messages from clients
# TYPE anycable_go_client_msg_total counter
anycable_go_client_msg_total 5906

# HELP anycable_go_failed_client_msg_total The total number of unrecognized messages received from clients
# TYPE anycable_go_failed_client_msg_total counter
anycable_go_failed_client_msg_total 0

# HELP anycable_go_broadcast_msg_total The total number of messages received through PubSub (for broadcast)
# TYPE anycable_go_broadcast_msg_total counter
anycable_go_broadcast_msg_total 956

# HELP anycable_go_failed_broadcast_msg_total The total number of unrecognized messages received through PubSub
# TYPE anycable_go_failed_broadcast_msg_total counter
anycable_go_failed_broadcast_msg_total 0

# HELP anycable_go_broadcast_streams_total The number of active broadcasting streams
# TYPE anycable_go_broadcast_streams_total gauge
anycable_go_broadcast_streams_total 0

# HELP anycable_go_rpc_call_total The total number of RPC calls
# TYPE anycable_go_rpc_call_total counter
anycable_go_rpc_call_total 15808

# HELP anycable_go_rpc_error_total The total number of failed RPC calls
# TYPE anycable_go_rpc_error_total counter
anycable_go_rpc_error_total 0

# HELP anycable_go_failed_auths_total The total number of failed authentication attempts
# TYPE anycable_go_failed_auths_total counter
anycable_go_failed_auths_total 0

# HELP anycable_go_goroutines_num The number of Go routines
# TYPE anycable_go_goroutines_num gauge
anycable_go_goroutines_num 5222

# HELP anycable_go_disconnect_queue_size The size of delayed disconnect
# TYPE anycable_go_disconnect_queue_size gauge
anycable_go_disconnect_queue_size 0


Another option is to periodically write stats to log (with info level). To enable metrics logging pass --metrics_log flag.

Your logs should contain smth like:

INFO 2018-03-06T14:16:27.872Z broadcast_msg_total=0 broadcast_streams_num=0 client_msg_total=0 clients_num=0 clients_uniq_num=0 context=metrics disconnect_queue_size=0 failed_auths_total=0 failed_broadcast_msg_total=0 failed_client_msg_total=0 goroutines_num=35 rpc_call_total=0 rpc_error_total=0

By default metrics are logged every 15 seconds (you can change this behaviour through --metrics_log_interval option).


First, try to run anycable-go --debug to enable verbose logging.

The most common problem is using different Redis channels within RPC instance and anycable-go. Find the following line in the logs:

INFO 2018-03-05T08:44:57.695Z context=pubsub Subscribed to Redis channel: __anycable__

and make sure, that RPC server publishes messages to the specified channel.


To secure your anycable-go server provide the paths to SSL certificate and private key:

anycable-go --port=443 -ssl_cert=path/to/ssl.cert -ssl_key=path/to/ssl.key

=> INFO 2018-03-05T08:44:57.684Z context=http Starting HTTPS server at




See available images here.

ActionCable Compatibility

Feature Status
Connection Identifiers +
Connection Request (cookies, params) +
Disconnect Handling +
Subscribe to channels +
Parameterized subscriptions +
Unsubscribe from channels +
Performing Channel Actions +
Streaming +
Usage of the same stream name for different channels +
Broadcasting +
Remote disconnect - (WIP)
Custom stream callbacks -
Subscription Instance Variables -


Bug reports and pull requests are welcome on GitHub at https://github.com/anycable/anycable-go.

Please, provide reproduction script (using this template) when submitting bugs if possible.


The library is available as open source under the terms of the MIT License.