问题描述
我是cpprest的新手,我试图用它来连接wss地址,这是显示问题的siplifed代码。
#include <iostream>
#include <string>
#include <cpprest/ws_client.h>
using namespace std;
using namespace web;
using namespace web::websockets::client;
int main()
{
websocket_client client;
client.connect(U("wss://echo.websocket.org/")).wait();
websocket_outgoing_message out_msg;
out_msg.set_utf8_message("hello");
client.send(out_msg).wait();
client.receive().then(
[](websocket_incoming_message msg)
{
return msg.extract_string();
}).then(
[](std::string body)
{
std::cout << body << std::endl;
}).wait();
client.close().then([](){cout << "closed" << endl;}).wait();
};
当我使用地址“ ws://echo.websocket.org/”时,它完全起作用。但是对于“ wss://echo.websocket.org/”,它将引发错误:
terminate called after throwing an instance of 'web::websockets::client::websocket_exception'
what(): set_fail_handler: 8: TLS handshake Failed
那么,我怎么能通过cpprest连接一个wss地址?如果您可以向我展示如何使用它,则可以征求其他更好的websocket框架的建议。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)