Connect Websocket with Poco libraries

后端 未结 2 1680
不知归路
不知归路 2021-01-03 09:23

I am trying to connect to the Echo Test Websocket using the Poco C++ libraries. In order to do so here is my code which should set up the Websocket:

HTTPClie         


        
2条回答
  •  抹茶落季
    2021-01-03 09:31

    The 'Not Found' error is the standard HTTP 404 Not Found returned by the HTTP server. It generally means the resource you are requesting does not exist.

    I got your code to work by changing the resource from "/ws" to "/":

    HTTPRequest request(HTTPRequest::HTTP_GET, "/");
    

    and adding the following line

    request.set("origin", "http://www.websocket.org");
    

    before creating the new WebSocket. I think it's a header pair that many (or all?) WebSocket servers expect.

提交回复
热议问题