Websocket example

This is a really simple example on how to use websockets in OB2.

BLOCK:WsConnect
  url = "wss://echo.websocket.org"
ENDBLOCK

BLOCK:WsSend
  message = "hello"
ENDBLOCK

BLOCK:Delay
  milliseconds = 1000
ENDBLOCK

BLOCK:WsRead
  => VAR @wsReadOutput
ENDBLOCK

BLOCK:WsDisconnect
ENDBLOCK

Note that this is just for testing. In most real-world scenarios you will need to first send an HTTP request to the HTTP webserver and then upgrade your connection to websocket.

You can read more about this here Protocol upgrade mechanism - HTTP | MDN

Ruri

3 Likes