talira

websocket_client (Erlang)

OTP-compliant WebSocket client for Erlang, over ws and wss

open sourceMITfree

websocket_client is a WebSocket client for Erlang. You write a callback module, much like a Cowboy WebSocket handler, and it connects over ws or wss (TCP or SSL), validates the handshake, masks frames, handles text, binary, ping, pong, close and continuation frames, and can send pings and keep the connection alive for you. It's OTP compliant and is now built on gen_statem. Michael Coles maintains it.

Problems it solves

  • connect to a WebSocket server from my Erlang application
  • an OTP websocket client with automatic reconnect and keepalive in Erlang
  • talk to a wss endpoint from Elixir or Erlang without writing the protocol myself

Features

  • callback-driven behaviour, like a Cowboy websocket handler
  • ws and wss (TCP and SSL) connections
  • handshake validation and client-to-server masking
  • text, binary, ping, pong, close and continuation frames
  • automatic ping/pong and keepalive
  • reconnect from the disconnect callback

Limitations

  • It uses verify_none for TLS by default (verifying the server's certificate is on its to-do list), and after its rework onto gen_statem its README says there may still be bugs.1

Alternatives

The same job

These do what websocket_client (Erlang) does.

  1. WebSockex An Elixir WebSocket client built on OTP processes

Compare websocket_client (Erlang) with the top 3