go get github.com/aacfactory/fns-contrib/transports/handlers/websockets
Only support json bytes.
Make sure tls is used.
app := fns.New(
fns.Handler(websockets.New())
)
Setup config
transport:
handlers:
websockets:
maxConnections: 1024
handshakeTimeout: "1s"
readTimeout: "10s"
readBufferSize: "4MB"
writeTimeout: "60s"
writeBufferSize: "4MB"
enableCompression: false
maxRequestMessageSize: "4KB"
connectionTTL: "10m0s"
enableEcho: false
originCheckPolicy:
mode: "pass"
Get connection id in function
connId := websockets.ConnectionId(ctx)
Send message to client
err := websockets.Send(ctx, connId, payload)