You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何关闭ESP8266 Socket-IO客户端的串口调试信息输出

Fixing Persistent [WS] Debug Logs in Socket.IO Client Project

Got it, let's tackle this problem head-on. Those [WS] prefixed logs you're seeing aren't coming from the SocketIOClient code you modified—they're actually from the underlying WebSocket client library that the socket.io-client depends on. Here's how you can shut them off completely:

  • Locate the WebSocket library's configuration file
    Look for a header file like WebSocketsClient.h (or similar, depending on the exact WebSocket library your project uses) in your libraries folder. Inside this file, search for debug-related macro definitions—common ones are #define WEBSOCKETS_DEBUG 1 or #define DEBUG_WEBSOCKETS. Change the value from 1 to 0, or comment out the entire line to disable debug output.

  • Manually strip debug prints from the WebSocket implementation
    If you can't find a debug toggle macro, open the WebSocket library's main implementation file (e.g., WebSocketsClient.cpp). Scan for all lines that use Serial.print(), Serial.println(), or any serial output calls that produce the [WS] logs. Comment out or delete these lines entirely. Pay close attention to blocks labeled sendFrame, handleWebsocketWaitFor, or readCb—those are the ones generating the logs you're seeing.

  • Double-check your project's serial initialization
    Make sure your own code isn't accidentally initializing the default Serial port (e.g., Serial.begin(115200) somewhere in setup()) that these debug logs are using. If you're only using Serial1 for your custom output, ensure no other parts of the code are enabling the primary Serial port.

  • Verify library dependencies in your build environment
    If you're using PlatformIO or Arduino IDE with library manager, confirm that you're modifying the correct instance of the WebSocket library (sometimes multiple versions can exist). Clean your build folder and recompile after making changes to ensure the modifications take effect.

Once you've applied these steps, those annoying [WS] debug logs should disappear entirely, leaving only your custom Serial1 output.

内容的提问来源于stack exchange,提问作者Roger Lee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:32:42