ws

package module
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: GPL-3.0 Imports: 15 Imported by: 1

README

ws transport

WebSocket transport for xtransport, built on gobwas/ws.

Installation

go get -u github.com/hkloudou/xtransport/transports/ws

Notes

  • Subprotocols("mqtt") enables RFC 6455 subprotocol negotiation, which standard MQTT-over-WebSocket clients (browsers, mqtt.js) require.
  • SetTimeOut is an idle interval: only data frames count as activity; WebSocket pings alone do not keep a connection alive.

Documentation

Index

Constants

View Source
const SessionKeySubprotocol = "ws:subprotocol"

SessionKeySubprotocol is the session key under which a listener-side socket stores the subprotocol negotiated during the WebSocket handshake (empty when none was negotiated).

Variables

This section is empty.

Functions

func NewTransport

func NewTransport(pattern string, opts ...xtransport.Option) xtransport.Transport

func Subprotocols added in v1.0.6

func Subprotocols(protos ...string) xtransport.Option

Subprotocols configures WebSocket subprotocol negotiation. A listener accepts the first protocol offered by the client that appears in protos and echoes it in the handshake response; Dial offers protos to the server. RFC 6455 clients (browsers, the Node ws package) abort the connection when they offered a subprotocol and the server selects none, so a server speaking MQTT over WebSocket must be configured with Subprotocols("mqtt") to accept standard MQTT clients such as mqtt.js.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址