Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EOF error #1775

Open
DerXanRam opened this issue Nov 1, 2023 · 0 comments
Open

EOF error #1775

DerXanRam opened this issue Nov 1, 2023 · 0 comments

Comments

@DerXanRam
Copy link

DerXanRam commented Nov 1, 2023

Hello guys. I'm using restcpp for subscribing and listening "pending transactions". But some times throws EOF error and my program brokes at runtime. My code sinnipet i use to subscribe web socket is

void socks()
{
    websocket_client client;
    client.connect("wss://bsc-mainnet.blastapi.io/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx").wait();
    string a = R"({"jsonrpc":"2.0","method":"eth_subscribe","params":["newPendingTransactions"],"id":1})";
    websocket_outgoing_message out_msg, unsub_w;

    out_msg.set_utf8_message(a);
    client.send(out_msg).wait();


    while (true)
    {
        client.receive().then([](websocket_incoming_message in_msg)
                              { return in_msg.extract_string(); })
            .then(
                [](string body)
                {
                    ret_str = body;
                    cout << j << " " << ret_str;
                })
            .wait();
        j++;
    }
    client.close().wait();
}

my question is how to avoid this error or how to catch it and handle it to prevent my program from sudden failure? please help 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant