Skip to main content

WebSocket Server Transport

Listens for a WebSocket client, for example a browser page or a device that connects out over WebSocket. Each frame is one message, so no codec is needed: text frames arrive as text messages, binary frames as binary ones, and outgoing binary payloads are sent as binary frames.

Only one client is served at a time; a new client replaces the current one. The Bind Address works as for the TCP Server: 0.0.0.0 accepts connections from the network, 127.0.0.1 only from this computer.

Configuration reference​

Config IDwebsocket_server_transport
Selected byapp_transport = "websocket_server_transport"
PlatformsLinux, Windows, Android
LicensePremium

WebSocket server accepting single client connection

Listening Configuration:

  • Bind Address: Local listening address
    • 0.0.0.0 - Listen on all network interfaces, allow any client to connect
    • 127.0.0.1 - Listen on loopback only, allow only local clients
    • Specific IP - Listen on specific network interface only
  • Bind Port: Port number the server will listen on

Operating Mode:

  • Server starts listening on the specified address and port
  • Automatically accepts WebSocket handshake requests
  • Supports only one client at a time, new connections replace old ones
  • Automatically waits for new connections after client disconnects
  • Uses standard WebSocket protocol, compatible with all WebSocket clients
SettingKeyTypeDefaultNotes
Bind Addresswebsocket_server_transport_bind_addressText"0.0.0.0"Required
Portwebsocket_server_transport_bind_portInteger9001Required

Example config​

Default values as they appear in a saved configuration (for example the JSON block at the end of a cycbox/examples/*.lua file). Settings detected at runtime are omitted.

{
"app": {
"app_transport": "websocket_server_transport"
},
"websocket_server_transport": {
"websocket_server_transport_bind_address": "0.0.0.0",
"websocket_server_transport_bind_port": 9001
}
}