oatpp / oatpp-websocket

oatpp-websocket submodule.
https://oatpp.io/
Apache License 2.0
83 stars 32 forks source link

Server response code=400 for an wss api which can be called with `websocat` tool #25

Closed innerNULL closed 3 years ago

innerNULL commented 3 years ago

Hi, really needs help about this problem, I'm writting a simple demo based on this example, and here is my codes, nothing wrong with compiling, but during running, I got this error:

 D |2021-04-17 13:25:11 1618637111939147| websocket-client:Init address.
 D |2021-04-17 13:25:11 1618637111940651| websocket-client:Finished init address.
 D |2021-04-17 13:25:11 1618637111940723| websocket-client:Init connector, URL: stream.data.alpaca.markets
 D |2021-04-17 13:25:11 1618637111940836| websocket-client:Init connection. Connect to: stream.data.alpaca.markets:443/v2/iex
 D |2021-04-17 13:25:12 1618637112703929| [oatpp::web::client::Connector::connectAndHandshake()]:Server response code=400
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: [oatpp::web::client::Connector::connectAndHandshake()]: Server responded with invalid code

but by runningwebsocat wss://stream.data.alpaca.markets:443//v2/iex I got [{"T":"success","msg":"connected"}] which means there is nothing wrong with wss api.

So, if there any possible reason caused Server response code=400?

THAAAAANKs

innerNULL commented 3 years ago

Oh my guess is, for wss proto, I should initialize connectionProvider with oatpp::mbedtls::Config::createDefaultClientConfigShared()?

innerNULL commented 3 years ago

Oh my guess is, for wss proto, I should initialize connectionProvider with oatpp::mbedtls::Config::createDefaultClientConfigShared()?

yep~that's it~

lganzzzo commented 3 years ago

Hey @innerNULL , Good that you've found the solution!