Add-Ons & Services

Connect Websocket with Poco libraries

Please post support and help requests here.

Connect Websocket with Poco libraries

Postby lion87 » 30 Aug 2013, 14:06

I am trying to connect to the Echo Test Websocket (http://www.websocket.org/echo.html) using the Poco C++ libraries. In order to do so,
here is my code which should set up the Websocket:
Code: Select all
HTTPClientSession cs("echo.websocket.org");
HTTPRequest request(HTTPRequest::HTTP_GET, "/ws");
HTTPResponse response;

WebSocket* m_psock = new WebSocket(cs, request, response);
m_psock->close(); //close immidiately

However it does not work: I am getting an error message like this:

Code: Select all
Poco::Exception: WebSocket Exception: Cannot upgrade to WebSocket connection: Not Found

Can anybody help?

kind regards
Posts: 3
Joined: 01 Aug 2013, 15:33

Re: Connect Websocket with Poco libraries

Postby richard » 01 Dec 2013, 10:43

The request version must be 1.1.

See: http://stackoverflow.com/questions/2018 ... ket-server
Posts: 2
Joined: 01 Dec 2013, 00:56

Re: Connect Websocket with Poco libraries

Postby treeze » Yesterday, 08:03

Hello !

Currently I'm facing similar issue :(


Code: Select all
HTTPClientSession cs( "echo.websocket.org" );

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

HTTPResponse response;

WebSocket* ws = new WebSocket( cs, request, response );

cs.sendRequest( request );

I'm getting:

Code: Select all
   throw ConnectionRefusedException(arg, code);

Someone willing to help ? :)
Posts: 2
Joined: Yesterday, 07:59

Re: Connect Websocket with Poco libraries

Postby gregee123 » Today, 01:04

Guys, where did you get the "/ws" or "/wss" paths from? WebSocket.org certainly doesn't seem to be using them.

Apart from that @trezee, if you want a secure connection you need HTTPSClientSession not HTTPClientSession but try plain HTTP first.
currently using: 1.5.3
Posts: 31
Joined: 29 Mar 2013, 12:11

Return to Support

Who is online

Users browsing this forum: No registered users and 5 guests