How do I connect to a websocket manually, with netcat/socat/telnet?

后端 未结 3 1691
情书的邮戳
情书的邮戳 2020-12-28 16:04

I am trying to connect to the reference websocket echo server \"manually\", in order to learn how the protocol works (I am using socat for that). However, the server invaria

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-28 16:25

    I think you want to modify the socket stream to translate \n (line feed) to CRLF (Carriage return & line feed). Doing info socat produces detailed information which includes this modifier:

    crnl   Converts the default line termination character NL ('\n',  0x0a)
           to/from CRNL ("\r\n", 0x0d0a) when writing/reading on this chan-
           nel (example).  Note: socat simply strips all CR characters.
    

    So I think you should be able to do this:

    socat - TCP:echo.websocket.org:80,crnl
    

提交回复
热议问题