I want to push video frames via WebSocket, where each frame is 3,110,400 bytes in size. After the connection is established, the client browser sends a message, and after the server receives it, it calls this->play(ws) to start pushing the video frames. However, after sending a few frames, the program crashes, and I don't know why the WebSocket connection is being closed. It has been confirmed that the issue is related to WebSocket, and it might be due to the size of the data being sent. The relevant code is as follows:
app->ws<PerSocketData>(api, {
.compression = uWS::DISABLED,
.maxPayloadLength = 64 * 1024 * 1024,
.idleTimeout = 60,
.maxBackpressure = 1024 * 1024 * 1024,
.closeOnBackpressureLimit = false,
.resetIdleTimeoutOnSend = true,
.sendPingsAutomatically = true,
.upgrade = nullptr,
.open = [](uWS::WebSocket<false, true, PerSocketData> *ws) {
std::cout << "open..." << std::endl;
},
.message = [this](uWS::WebSocket<false, true, PerSocketData> *ws, std::string_view message,
uWS::OpCode opCode) {
std::thread t([this, ws]() {
this->play(ws);
});
t.detach();
void play(uWS::WebSocket<false, true, PerSocketData> *ws) {
try {
video::start([ws](std::string_view frame_data) -> void {
ws->send(frame_data, uWS::OpCode::BINARY);
});
}
I want to push video frames via WebSocket, where each frame is 3,110,400 bytes in size. After the connection is established, the client browser sends a message, and after the server receives it, it calls this->play(ws) to start pushing the video frames. However, after sending a few frames, the program crashes, and I don't know why the WebSocket connection is being closed. It has been confirmed that the issue is related to WebSocket, and it might be due to the size of the data being sent. The relevant code is as follows:
app->ws<PerSocketData>(api, { .compression = uWS::DISABLED, .maxPayloadLength = 64 * 1024 * 1024, .idleTimeout = 60, .maxBackpressure = 1024 * 1024 * 1024, .closeOnBackpressureLimit = false, .resetIdleTimeoutOnSend = true, .sendPingsAutomatically = true, .upgrade = nullptr, .open = [](uWS::WebSocket<false, true, PerSocketData> *ws) { std::cout << "open..." << std::endl; }, .message = [this](uWS::WebSocket<false, true, PerSocketData> *ws, std::string_view message, uWS::OpCode opCode) { std::thread t([this, ws]() { this->play(ws); }); t.detach();