Skip to content

transport: option to set the WS and WSS handshake path - #339

Open
Mliviu79 wants to merge 2 commits into
emiago:mainfrom
Mliviu79:pr/ws-dialpath-option
Open

transport: option to set the WS and WSS handshake path#339
Mliviu79 wants to merge 2 commits into
emiago:mainfrom
Mliviu79:pr/ws-dialpath-option

Conversation

@Mliviu79

Copy link
Copy Markdown
Contributor

Fixes #338

Stacked on #320, which makes WSS honour DialURI at all. Please take that first — the diff here is only the option on top.

Most SIP over WebSocket servers expect /ws while the dialer requests /. DialURI already expresses this, but nothing could set it short of supplying a whole transport through WithTransportLayerTransports — which means hand-constructing TransportWS/TransportWSS just to change a path.

WithTransportLayerWSDialPath appends a handshake path to the default WS and WSS DialURI built in NewTransportLayer. Per transport layer rather than a package global, so two user agents in one process can dial different paths. Ignored for a transport supplied through WithTransportLayerTransports, since that one carries its own DialURI.

One exported option, no behaviour change when unset.

Liviu Muresan added 2 commits July 19, 2026 09:58
NewTransportLayer sets a DialURI default for WSS, but TransportWSS declares its
own CreateConnection, which shadows the promoted TransportWS method and builds
the handshake URL from a hardcoded "wss://" + addr. The field is never read on
that path, so a caller setting a handshake path has no effect over WSS and the
dialer always requests /.

CreateConnection now reads t.DialURI(addr). TransportWSS.init sets the wss://
default before calling TransportWS.init, which would otherwise default it to
ws:// and dial the wrong scheme over TLS.

Refs emiago#319
Most SIP over WebSocket servers expect /ws, while the dialer requests /.
DialURI already expresses this but nothing could set it, so the path was
reachable only by supplying a whole transport through TransportsConfig.

Set it per transport layer instead of a package global, so two user
agents in one process can dial different paths.
Refs emiago#338
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sip: no way to set the WS/WSS handshake path

1 participant