Overview
Features
Download
Documentation
Community
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
lion87
 
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
richard
 
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 :(

After:

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
case POCO_ECONNREFUSED:
   throw ConnectionRefusedException(arg, code);


Someone willing to help ? :)
treeze
 
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
gregee123
 
Posts: 31
Joined: 29 Mar 2013, 12:11


Return to Support

Who is online

Users browsing this forum: No registered users and 5 guests

cron