websocketpp
websocketpp copied to clipboard
Server handshake response error: websocketpp.processor:20 (Invalid HTTP status.)
I get the following error when I try to connect.
Server handshake response error: websocketpp.processor:20 (Invalid HTTP status.)
How would I get the actual response from the server or understand what is going wrong?
Have you solved this problem?
Also hoping for an answer
Getting the same thing too. Anyone has an update?
I have the same problem.
I have this same issue when running the print_client example. Can anyone help please?
Thank you so much David. I got the print_client_tls working by disabling the verify_certificate function, but this print_client issue remains.
From: David St-Louis [email protected] Sent: Tuesday, February 19, 2019 8:40:13 PM To: zaphoyd/websocketpp Cc: Jacob Jiang; Mention Subject: Re: [zaphoyd/websocketpp] Server handshake response error: websocketpp.processor:20 (Invalid HTTP status.) (#648)
@j-fabhttps://github.com/j-fab I got WebSockets working as both client and server, so I solved this. Let me dig in my commit history and I'll come back to you.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/zaphoyd/websocketpp/issues/648#issuecomment-465113384, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ArzreI_jJh1LH9EADM90RZp20Aa8SktHks5vO_CtgaJpZM4NeP-T.
hi, I encountered this error message during the use of socket.io-client-cpp. The problem I encountered was that the ssl was not compiled, the https used when setting the url was wrong, and it returned to normal when I used http. Hope to be helpful to this problem.
@chunqiulfq I also meet this problem.did you build socket.io-client-cpp with boost?
in my case, it was just due a difference in the path, my socket io server was listening on /path
and the client was connection on /
verify_certificate
Could you list the function and paramters? thanks
怎么解决的? 求留言
@warrially 看一下 监听路径 和 连接路径 是否完全匹配。 如果监听的是wss://192.168.0.100:8008/ws/, 而客户端连接的时候,缺使用了wss://192.168.0.100:8008/ws。少了一个斜线。 zak905表达的应该就是这个意思吧。
@warrially 看一下 监听路径 和 连接路径 是否完全匹配。 如果监听的是wss://192.168.0.100:8008/ws/, 而客户端连接的时候,缺使用了wss://192.168.0.100:8008/ws。少了一个斜线。 zak905表达的应该就是这个意思吧。
已经搞定了, 知道是什么原因了. 他这个库有问题. 少了Origin, 在源码里加上就好了., 谢谢
share 一下
share 一下
template
// TODO: origin header? 这里tmd偷工减料? 这河里妈?
// Have the protocol processor fill in the appropriate fields based on the // selected client version if (m_processor) { lib::error_code ec; ec = m_processor->client_handshake_request(m_request,m_uri, m_requested_subprotocols);
if (ec) { log_err(log::elevel::fatal,"Internal library error: Processor",ec); return; } } else { m_elog->write(log::elevel::fatal,"Internal library error: missing processor"); return; }
/// Fill in a set of request headers for a client connection request
/**
* @param [out] req Set of headers to fill in
* @param [in] uri The uri being connected to
* @param [in] subprotocols The list of subprotocols to request
*/
lib::error_code client_handshake_request(request_type & req, uri_ptr
uri, std::vector<std::string> const & subprotocols) const
{
req.set_method("GET");
req.set_uri(uri->get_resource());
req.set_version("HTTP/1.1");
req.append_header("Origin", "http://www.baidu.com/"); // 在这里补上 Origin 后正常
// add origin and fix it ..
req.append_header("Upgrade","websocket");
req.append_header("Connection","Upgrade");
req.replace_header("Sec-WebSocket-Version","13");
req.replace_header("Host",uri->get_host_port());
/// Fill in a set of request headers for a client connection request /** * @param [out] req Set of headers to fill in * @param [in] uri The uri being connected to * @param [in] subprotocols The list of subprotocols to request */ lib::error_code client_handshake_request(request_type & req, uri_ptr uri, std::vector<std::string> const & subprotocols) const { req.set_method("GET"); req.set_uri(uri->get_resource()); req.set_version("HTTP/1.1"); req.append_header("Origin", "http://www.baidu.com/"); // 在这里补上 Origin 后正常 // add origin and fix it .. req.append_header("Upgrade","websocket"); req.append_header("Connection","Upgrade"); req.replace_header("Sec-WebSocket-Version","13"); req.replace_header("Host",uri->get_host_port());
路径错了就会导致这个报错,而且 client::connection_ptr 下有append_header con->append_header("Origin", "xxxxxx");就好了,不需要去改源码
For me using the encoded URL solved the problem. I am not sure when I am going to find time to code a proper fix for this repository, but meanwhile following should help or at least send some of you in the right direction (hopefully).
if the problematic url is: wss://ws.host.com/?api_key=someApiKeyContaining/+=Etc&enctoken=someEncTokenContaining/+=Etc
then following encoded url should work: wss://ws.host.com/?api_key=someApiKeyContaining%2F%2B%3DEtc&enctoken=someEncTokenContaining%2F%2B%3DEtc
Settle in this way.
client::connection_ptr con = echo_client.get_connection( uri, ec ); con->append_header("access-control-allow-origin", "*"); echo_client.connect( con );