You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello guys. I'm using this lib for subscribing web socket and i want to set timeout for the socket connection. Cause sometimes the receive call back function stops receiving data and freezes. This is my code
void sock()
{
websocket_callback_client client;
client.connect("wss://bsc-mainnet.infura.io/xxxx-xxx--xxxxx").wait();
std::string body_str = R"({"jsonrpc":"2.0","method":"eth_subscribe","params":["newPendingTransactions"],"id":1})";
std::vector<unsigned char> body(body_str.begin(), body_str.end());
pplx::task_completion_event<void> receiveEvent;
// make sure client works fine without setting receive handler
websocket_outgoing_message msg;
msg.set_utf8_message(body_str);
client.send(msg).wait();
// set receive handler
client.set_message_handler([body_str, &receiveEvent](websocket_incoming_message ret_msg)
{
auto body = ret_msg.extract_string().get();
ret_str = body;
cout << j << " " << ret_str;
j++;
if(false)
{
receiveEvent.set();
} });
client.send(msg);
pplx::create_task(receiveEvent).wait();
client.close().wait();
}
The text was updated successfully, but these errors were encountered:
Hello guys. I'm using this lib for subscribing web socket and i want to set timeout for the socket connection. Cause sometimes the
receive
call back function stops receiving data and freezes. This is my codeThe text was updated successfully, but these errors were encountered: