Connecting to websocket using C# (I can connect using JavaScript, but C# gives Status code 200 error)

后端 未结 6 1769
情书的邮戳
情书的邮戳 2021-01-30 07:38

I am new in the area of websocket.

I can connect to websocket server using JavaScript using this code:

var webSocket = new WebSocket(url);
6条回答
  •  无人共我
    2021-01-30 08:02

    If you connect with a WebSocket client and you get an HTTP 200 as response, means that probably you are connecting to the wrong place (host, path and/or port).

    Basically, you are connecting to a normal HTTP endpoint that is not understanding your WebSocket requirement, and it is just returning the "OK" response (HTTP 200). Probably the WebSocket server runs in another port or path in the same server.

    Check your URL.

提交回复
热议问题