boostorg / beast

HTTP and WebSocket built on Boost.Asio in C++11
http://www.boost.org/libs/beast
Boost Software License 1.0
4.37k stars 635 forks source link

websocket cannot connect to www.bitmex.com #1081

Closed youngkylejan closed 6 years ago

youngkylejan commented 6 years ago

bitmex websocket api: https://www.bitmex.com/app/wsAPI

use the websocket_client_async_ssl example to start the connection to www.bitmex.com

but it always handshake failed. it returns "unknown protocol" or "wrong version number" error message

vinniefalco commented 6 years ago

Well what do the HTTP headers that come back look like?

youngkylejan commented 6 years ago

how to get the http headers before async_handshake in beast?

vinniefalco commented 6 years ago

Use the overload of async_handshake which fills out the response: http://www.boost.org/doc/libs/1_66_0/libs/beast/doc/html/beast/using_websocket/handshaking_clients.html#beast.using_websocket.handshaking_clients.filtering http://www.boost.org/doc/libs/1_66_0/libs/beast/doc/html/beast/ref/boost__beast__websocket__stream/async_handshake/overload2.html

youngkylejan commented 6 years ago

oh sorry. i am not describe the problem clearly. i fail on the websocket::stream::ssl_stream::async_handshake, which use to do the ssl handshake.

vinniefalco commented 6 years ago

Oh...well, I have no idea why that would fail. Perhaps contact BitMEX? Or look up common reasons why SSL handshakes produce those errors: http://blog.techstacks.com/2010/03/3-common-causes-of-unknown-ssl-protocol-errors-with-curl.html

youngkylejan commented 6 years ago

gotcha, thx!