Skip to content

Commit c903d40

Browse files
committed
设置 WebSocket 非阻塞
1 parent f5e40a0 commit c903d40

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

candy/src/websocket/client.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ int WebSocketClient::connect() {
390390
spdlog::critical("invalid websocket scheme: {}", wsServerUri);
391391
return -1;
392392
}
393+
// Blocking mode may cause receiveFrame to hang and use 100% CPU
394+
this->ws->setBlocking(false);
393395
this->timestamp = bootTime();
394396
this->pingMessage = fmt::format("candy::{}::{}::{}", CANDY_SYSTEM, CANDY_VERSION, hostName());
395397
spdlog::debug("client info: {}", this->pingMessage);

0 commit comments

Comments
 (0)