当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby - How to verify Websocket connection using script?

问题描述:

I want to automate and monitor my websocket connection whether it is able to send successful response for the connection request. I know different plugins already available but I am looking for a script whether in bash or ruby so that it can test my websocket connection and successful message .

Any help will be very much appreciated .

网友答案:

Run

curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: echo.websocket.org" -H "Origin: http://www.websocket.org" http://echo.websocket.org

Where http://www.websocket.org is host origin, and echo.websocket.org is endpoint for websocket.

Those flags say:

  • Return headers in the output
  • Dont buffer the response
  • Set a header that this connection needs to upgrade from HTTP to something else
  • Set a header that this connection needs to upgrade to a WebSocket connection
  • Set a header to define the host (required by later WebSocket standards)
  • Set a header to define the origin of the request (required by later WebSocket standards)

If your WebSocket is working running the above should return the handshake information, for further information, refer to this post

分享给朋友:
您可能感兴趣的文章:
随机阅读: