ws_client (ws v0.1.1)

View Source

WebSocket client connect for ws:// / wss:// URLs.

The client connects over plain TCP (ws) or TLS (wss), sends the HTTP/1.1 upgrade request, validates the 101 response, and starts a ws_session running in client mode.

HTTP/2 and HTTP/3 client flows piggy-back on an already-established H2/H3 connection owned by the embedder; they are driven through ws_h2_upgrade / ws_h3_upgrade plus a transport adapter the embedder supplies, not through this module.

Summary

Types

opts/0

-type opts() ::
          #{handler := module(),
            handler_opts => term(),
            subprotocols => [binary()],
            extensions => [binary()],
            origin => binary(),
            extra_headers => [{binary(), binary()}],
            timeout => timeout(),
            max_handshake_size => pos_integer(),
            ssl_opts => list(),
            parser_opts => map()}.

url/0

-type url() :: binary() | string().

Functions

connect(Url, Opts)

-spec connect(url(), opts()) -> {ok, pid()} | {error, term()}.