Phoenix.Transports.WebSocket

Socket transport for websocket clients.

Configuration

The websocket is configurable in your socket:

transport :websocket, Phoenix.Transports.WebSocket,
  timeout: :infinity,
  serializer: Phoenix.Transports.WebSocketSerializer,
  transport_log: false
  • :timeout - the timeout for keeping websocket connections open after it last received data

  • :transport_log - if the transport layer itself should log and, if so, the level

  • :serializer - the serializer for websocket messages

  • :check_origin - if we should check the origin of requests when the origin header is present. It defaults to true and, in such cases, it will check against the host value in YourApp.Endpoint.config(:url)[:host]. It may be set to false (not recommended) or to a list of explicitly allowed origins

Serializer

By default, JSON encoding is used to broker messages to and from clients. A custom serializer may be given as module which implements the encode!/1 and decode!/2 functions defined by the Phoenix.Transports.Serializer behaviour.

The encode!/1 function must return a tuple in the format {:socket_push, :text | :binary, String.t | binary}.

Source

Summary

default_config()

Callback implementation for Phoenix.Socket.Transport.default_config/0

handlers()

Callback implementation for Phoenix.Socket.Transport.handlers/0

Functions

default_config()

Callback implementation for Phoenix.Socket.Transport.default_config/0.

Source
handlers()

Callback implementation for Phoenix.Socket.Transport.handlers/0.

Source