Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

websocket - How to debug a C++ REST SDK (Casablanca) exception?

This code is intended to connect to a websocket server and send a text string.

When I run it inside the Visual Studio 2019 IDE, it throws a vaguely worded exception (Exception Thrown - casablanca_test.exe has triggered a breakpoint) after the call to client.send().

I assume I'm doing something wrong with send() - if I leave that out the connection seems to open and closes correctly - but I have no idea what. How do I even begin to debug this?

// This is a complete program, but assumes the cpprestsdk package is installed,
// which in turn requires OpenSSL

#include <iostream>

#include <cpprest/ws_client.h>

using namespace utility;                    // Common utilities like string conversions
using namespace web;                        // Common features like URIs.
using namespace web::web_sockets::client;     // WebSockets client

int main()
{
    websocket_client client;

    client.connect(U("wss://echo.websocket.org")).then([]()
        {
            OutputDebugStringA("returned from .connect()
");
        });

    OutputDebugStringA("After client.connect()
"); // <== this is fine

    websocket_outgoing_message msg;
    msg.set_utf8_message("hello");
    client.send(msg).then([]()
        {
            OutputDebugStringA("returned from .send()
");
        });

    OutputDebugStringA("After client.send()
"); // <== exception reported here

    client.close().then([]() 
        { 
            OutputDebugStringA("returned from .close()
"); 
        });
}

This is the exception message: The exception message

question from:https://stackoverflow.com/questions/65713446/how-to-debug-a-c-rest-sdk-casablanca-exception

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...