我正在尝试与远程服务器建立 websocket 连接并收到以下错误:WebSocket 握手被远程对等方拒绝
我正在关注这个例子:https : //www.boost.org/doc/libs/1_70_0/libs/beast/example/websocket/client/sync/websocket_client_sync.cpp
对于以下服务器:https : //api.hitbtc.com/#socket-api-reference
提前感谢您的帮助!
int main(int argc, char** argv) {
try
{
auto const host = "api.hitbtc.com";
auto const port = "443";
net::io_context ioc;
tcp::resolver resolver{ ioc };
websocket::stream<tcp::socket> ws{ ioc };
auto const results = resolver.resolve(host, port);
net::connect(ws.next_layer(), results.begin(), results.end());
// Perform the websocket handshake - this is where i presume the issue is.
ws.handshake(host, "/api/2/ws");
beast::flat_buffer buffer;
ws.read(buffer);
ws.close(websocket::close_code::normal);
std::cout << beast::make_printable(buffer.data()) << std::endl;
}
catch (std::exception const& e) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Beast 制作一个 CMake 项目,并且它已从 中的源代码正确安装/usr/local/include/boost,但我无法让 CMake 找到它。不过,我觉得这可能是一个3.10.2,所以我累3.11.4和3.12.0-rc1,但既不工作。有谁知道该怎么做?
环境:Windows CLion 2018.1.5 和 WSL 上的 Ubuntu 18.04LTS。
尝试运行 CMake 时,出现以下错误:
CMake Warning at /home/aidan/Apps/cmake-3.11.4-Linux-x86_64/share/cmake-3.11/Modules/FindBoost.cmake:1723 (message):
No header defined for beast; skipping header check
Call Stack (most recent call first):
CMakeLists.txt:15 (find_package)
CMake Error at /home/aidan/Apps/cmake-3.11.4-Linux-x86_64/share/cmake-3.11/Modules/FindBoost.cmake:2044 (message):
Unable to find the requested Boost libraries.
Boost version: 1.67.0
Boost include path: /usr/local/include
Could not find the following Boost libraries:
boost_beast
Some (but not all) of …Run Code Online (Sandbox Code Playgroud)