OffBroadwayWebSocket.Producer accepts these primary options.
:url- websocket base URL:path- request path and query string if needed
:ws_timeout- idle timeout in milliseconds:await_timeout- timeout for:gun.await_up/2:headers- websocket upgrade headers:headers_fn- optional zero-arity callback for per-connect header refresh:telemetry_id- prefix for telemetry events:gun_opts- options forwarded to:gun:min_demand/:max_demand- Broadway producer demand settings
:ws_retry_opts- retry state map:ws_retry_fun- function used to compute the next retry state
The default retry state is:
%{
max_retries: 5,
retries_left: 5,
delay: 10_000
}:on_upgrade- optional MFA run after websocket upgrade and before readiness:frame_handler- optional MFA run for normalized inbound data frames:frame_handler_state- initial connection-local state for:frame_handler
Use static :headers when auth headers are long-lived.
Use :headers_fn when headers need to be refreshed each reconnect.
headers_fn may return:
[{"header", "value"}]{:ok, [{"header", "value"}]}{:error, reason}(connection attempt fails and retry/backoff applies)
Use :gun_opts to configure:
- transport (
:tcpor:tls) - TLS verification
- HTTP version
- websocket keepalive and ping behavior
Example:
gun_opts: %{
connect_timeout: 5_000,
protocols: [:http],
transport: :tls,
tls_opts: [
verify: :verify_peer,
cacertfile: CAStore.file_path()
],
ws_opts: %{
keepalive: 10_000,
silence_pings: false
},
http_opts: %{
version: :"HTTP/1.1"
}
}