Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k 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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...