如何解决如何调试 C++ REST SDK (Casablanca) 异常?
此代码旨在连接到 websocket 服务器并发送文本字符串。
当我在 Visual Studio 2019 IDE 中运行它时,它会在调用 Exception Thrown - casablanca_test.exe has triggered a breakpoint
后抛出一个措辞含糊的异常 (client.send()
)。
我认为我在使用 send()
时做错了 - 如果我忽略它,连接似乎可以正确打开和关闭 - 但我不知道是什么。我该如何开始调试?
// 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()\n");
});
OutputDebugStringA("After client.connect()\n"); // <== this is fine
websocket_outgoing_message msg;
msg.set_utf8_message("hello");
client.send(msg).then([]()
{
OutputDebugStringA("returned from .send()\n");
});
OutputDebugStringA("After client.send()\n"); // <== exception reported here
client.close().then([]()
{
OutputDebugStringA("returned from .close()\n");
});
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。