Search code examples
nginxgomattermost

What is the protocol for a secure websocket?


We've installed a Mattermost server and it works well.

We can only connect via http. Https gives an error.

The line of code that fails is

webSocketClient, err := model.NewWebSocketClient4("ws://mattermost.example.com", client.AuthToken)

make run
go run   *.go
Mattermost Bot Sample
Server detected and is running version 5.1.0
We failed to connect to the web socket
    Error Details:
        model.websocket_client.connect_fail.app_error
        model.websocket_client.connect_fail.app_error
        websocket: bad handshake
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x58 pc=0x13e1e55]

We opened up the http port 8065 and when we connect to port 8065, without ssl, it works.

webSocketClient, err := model.NewWebSocketClient4("ws://mattermost.example.com:8065", client.AuthToken)

What is the protocol for a secure websocket?


Solution

  • Normal websocket uses "ws://example.com"

    Secure websocket uses "wss://example.com"

    Note that some frameworks automatically handle this for you if you just leave off the ws: or wss: entirely.