Erlang WebSockets client
Erlang Ruby
Latest commit 3fbff7f Aug 9, 2014 @madtrick Merge pull request #19 from fenek/fix-reloader-dep
Fix reloader dependency

Analytics Build Status


A WebSocket client written in Erlang


  • Built using wsock
  • Supports both "ws://" and "wss://" schemes.
  • Offers callbacks for events that might occur during the client life: on_open, on_close, on_message and on_error.

Supported protocol versions

Only the protocol specificied at RFC6455 (version 13) is supported. Notice that currently, neither subprotocols nor extensions are supported.


Add this repo as a dependency to your rebar.config file

{wsecli, ".*", {git, "", {tag, master}}}

and then

./rebar compile


I will demostrate its usage with the echo service at

  1. Start it, using the function wsecli:start/4

    1>wsecli:start("", 80, "/", []).

    or the function wsecli:start/2

    2>wsecli:start("ws://", []).

    The valid options for the client are:

    • {registered, true | false | atom()}. When true the client will be registered using the default name wsecli, when false it will not be registered and any other atom will be used as the name to register with. By default it will not be registered.
  2. Add a callback for received messages,

    3>wsecli:on_message(fun(text, Message)-> io:format("Echoed message: ~s ~n", [Message]) end).
  3. Send a message that will be echoed,

    4> wsecli:send("Hello").
    Echoed message: Hello
  4. And finally to stop it



Callbacks for the events: on_open, on_error, on_message and on_close can be added. Check the code or the documentation for details.


Unit tests

Unit test where done with the library espec by lucaspiller.

To run them

  rake spec

or, in case you don't have rake installed,

  ./rebar compile && ERL_LIBS='deps/' ./espec test/spec/


  • Support streaming of data.
  • Support subprotocol and extensions.


Farruco Sanjurjo. You can contact me at:


Copyright [2013] [Farruco Sanjurjo Arcay]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


If you find or think that something isn't working properly, just open an issue.

Pull requests and patches (with tests) are welcome.