Skip to main content

Module ws

Module ws 

Source
Expand description

SIP over WebSocket (RFC 7118).

Two things make this a transport of its own rather than TCP with a wrapper round it, and both come from docs/specs/sip-tls.md §4.

The frame is the message. RFC 7118 §5 puts exactly one SIP message in each WebSocket message — not Content-Length framing, which is what every other stream transport here uses. So a peer that sends half a message, or two, has not sent something sipx should try to make sense of; it has revealed that it does not agree about where messages begin.

The client cannot be connected back to. A browser has no listening port, so its Via sent-by is an invented name that will never resolve, and everything sipx sends it goes back over the connection it came in on. That is the RFC 5923 rule from the TCP transport made absolute: here there is no fallback, because there is nowhere to fall back to.

WSS is this module over the TLS from crate::tls — the same certificate policy and the same code, because a second implementation of a security check is how one of the two ends up weaker.

Enums§

WsError
What can go wrong establishing a WebSocket.

Constants§

SUBPROTOCOL
The subprotocol name RFC 7118 §4.2 registers.

Functions§

accept
Perform the server half, refusing a peer that does not offer the sip subprotocol.
connect
Perform the client half of the handshake, asking for the sip subprotocol at path.
invented_sent_by
A Via sent-by for an endpoint that can never be connected back to (RFC 7118 §5.2).

Type Aliases§

Socket
A negotiated WebSocket carrying SIP.