Open bigcattus opened 7 years ago
Two things I'd look at:
On Jul 4, 2017, at 11:00, bigcattus notifications@github.com wrote:
I am trying to adopt that example (from the dev branch) to connect to coinbase websocket feed.
The only changes I made are in main() which I am pasting below. The errors I am getting are:
[2017-07-04 10:55:46] [application] Connecting to wss://ws-feed-public.sandbox.gdax.com [2017-07-04 10:55:46] [connect] Successful connection [2017-07-04 10:55:46] [error] handle_read_http_response error: websocketpp.transport:7 (End of File) [2017-07-04 10:55:46] [fail] WebSocket Connection 34.198.126.197:443 - "WebSocket++/0.7.0" / 0 websocketpp.transport:7 End of File
Where should I start looking? Thank you.
int main(int argc, char* argv[]) { client c;
std::string uri = "wss://ws-feed-public.sandbox.gdax.com"; try { // Set logging to be pretty verbose (everything except message payloads) c.set_access_channels(websocketpp::log::alevel::all); //c.clear_access_channels(websocketpp::log::alevel::frame_payload); c.set_error_channels(websocketpp::log::elevel::all);
// Initialize ASIO c.init_asio(); // Register our message handler c.set_message_handler(&on_message); //c.set_tls_init_handler(bind(&on_tls_init, hostname.c_str(), ::_1)); c.set_tls_init_handler([](websocketpp::connection_hdl) { return websocketpp::lib::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::tlsv1); }); websocketpp::lib::error_code ec; client::connection_ptr con = c.get_connection(uri, ec); if (ec) { std::cout << "could not create connection because: " << ec.message() << std::endl; return 0; } // Note that connect here only requests a connection. No network messages are // exchanged until the event loop starts running in the next line. c.connect(con); c.get_alog().write(websocketpp::log::alevel::app, "Connecting to " + uri); // Start the ASIO io_service run loop // this will cause a single connection to be made to the server. c.run() // will exit when this connection is closed. c.run();
} catch (websocketpp::exception const & e) { std::cout << e.what() << std::endl; } }
― You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Thank you! I made the changes you suggested, and modified the code to work with echo.websocket.org. It connected and sent messages. However with coinbase, it looks like the server closes the socket right after the handshake. I'll try again tomorrow in case the service is closed on a holiday.
GET / HTTP/1.1 Connection: Upgrade Host: ws-feed-public.sandbox.gdax.com Sec-WebSocket-Key: AAAAAAAAAAAAAAAAAAAAAA== Sec-WebSocket-Version: 13 Upgrade: websocket User-Agent: WebSocket++/0.7.0
[2017-07-04 13:46:57] [devel] asio post init timer cancelled [2017-07-04 13:46:57] [devel] handle_send_http_request [2017-07-04 13:46:57] [devel] asio async_read_at_least: 1 [2017-07-04 13:46:57] [devel] asio con handle_async_read [2017-07-04 13:46:57] [devel] handle_read_http_response [2017-07-04 13:46:57] [error] handle_read_http_response error: websocketpp.transport:7 (End of File) [2017-07-04 13:46:57] [devel] connection terminate [2017-07-04 13:46:57] [fail] WebSocket Connection 34.198.126.197:443 - "WebSocket++/0.7.0" / 0 websocketpp.transport:7 End of File [2017-07-04 13:46:57] [devel] asio connection async_shutdown [2017-07-04 13:46:57] [devel] open handshake timer cancelled [2017-07-04 13:46:57] [devel] asio con handle_async_shutdown [2017-07-04 13:46:57] [devel] connection handle_terminate [2017-07-04 13:46:57] [devel] asio socket shutdown timer cancelled
I am trying to adopt that example (from the dev branch) to connect to coinbase websocket feed.
The only changes I made are in main() which I am pasting below. The errors I am getting are:
[2017-07-04 10:55:46] [application] Connecting to wss://ws-feed-public.sandbox.gdax.com [2017-07-04 10:55:46] [connect] Successful connection [2017-07-04 10:55:46] [error] handle_read_http_response error: websocketpp.transport:7 (End of File) [2017-07-04 10:55:46] [fail] WebSocket Connection 34.198.126.197:443 - "WebSocket++/0.7.0" / 0 websocketpp.transport:7 End of File
Where should I start looking? Thank you.
int main(int argc, char* argv[]) { client c;
}