typedef websocketpp::client client;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// pull out the type of messages sent by our config
typedef websocketpp::config::asio_tls_client::message_type::ptr message_ptr;
typedef websocketpp::lib::shared_ptr context_ptr;
typedef client::connection_ptr connection_ptr;
int main(int argc, char* argv[]) {
std::string uri = "wss://v3demo.mediasoup.org:4443/?roomId=b3pcftkc&peerId=3ck2s9kh";//"wss://webrtc.yuntongxun.net:4443 -->this is ok";
when i use websocketpp to connect to local host or mediasoup demo, the client connect failed with below err.
The websocketpp client failed:
[2020-12-24 15:57:53] [connect] Successful connection [2020-12-24 15:57:53] [error] Server handshake response error: websocketpp.processor:20 (Invalid HTTP status.) [2020-12-24 15:57:53] [fail] WebSocket Connection 192.168.1.41:4443 - "WebSocket++/0.8.2" /?roomId=wuodujbw&peerId=ytev7jq1 403 websocketpp.processor:20 Invalid HTTP status. Fail handler 3 1006 Invalid HTTP status. 1006
websocketpp.processor:20 - Invalid HTTP status.
and the mediasoup server logs:
protoo-server:WARN:WebSocketServer _onRequest() | invalid/missing Sec-WebSocket-Protocol
the websocketpp client:
define ASIO_STANDALONE
include <websocketpp/config/asio_client.hpp>
include <websocketpp/client.hpp>
include
include
typedef websocketpp::client client;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
// pull out the type of messages sent by our config typedef websocketpp::config::asio_tls_client::message_type::ptr message_ptr; typedef websocketpp::lib::shared_ptr context_ptr;
typedef client::connection_ptr connection_ptr;
const char* request = "{\"request\":true,\"id\":6575451,\"method\":\"getRouterRtpCapabilities\",\"data\":{}}";
class perftest { public: typedef perftest type; typedef std::chrono::duration<int,std::micro> dur_type;
private: client m_endpoint; std::thread t1; std::chrono::high_resolution_clock::time_point m_start; std::chrono::high_resolution_clock::time_point m_socket_init; std::chrono::high_resolution_clock::time_point m_tls_init; std::chrono::high_resolution_clock::time_point m_open; std::chrono::high_resolution_clock::time_point m_message; std::chrono::high_resolution_clock::time_point m_close; };
int main(int argc, char* argv[]) { std::string uri = "wss://v3demo.mediasoup.org:4443/?roomId=b3pcftkc&peerId=3ck2s9kh";//"wss://webrtc.yuntongxun.net:4443 -->this is ok";
}