如何调试Websocket?

发布于 2024-09-27 03:50:27 字数 89 浏览 4 评论 0原文

我想监视 websocket 流量(例如查看客户端/服务器正在使用的协议版本)以进行调试。我该怎么做呢? Wireshark 对于这样的任务来说似乎太低级了。建议?

I want to monitor the websocket traffic (like to see what version of the protocol the client/server is using) for debugging purposes. How would I go about doing this? Wireshark seems too low level for such a task. Suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

巴黎夜雨 2024-10-04 03:50:27

Wireshark 听起来就像你真正想要的。握手后 WebSocket 几乎没有框架或结构(因此您需要低级),即使有,wireshark 也很快(或已经)能够解析它并向您显示结构。

就我个人而言,我经常使用 tcpdump 捕获数据,然后使用wireshark 解析数据。当您可能无法在想要捕获数据的设备(即无头服务器)上使用wireshark时,这尤其有用。例如:

sudo tcpdump -w /tmp/capture_data -s 8192 port 8000

或者,如果您可以控制 WebSockets 服务器(或代理),您可以随时打印出发送和接收的数据。请注意,由于 websocket 框架以 '\x00' 开头,因此希望避免打印它,因为在许多语言中 '\x00' 意味着字符串的结尾。

Wireshark sounds like what you want actually. There is very little framing or structure to WebSockets after the handshake (so you want low-level) and even if there was, wireshark would soon (or already) have the ability to parse it and show you the structure.

Personally, I often capture with tcpdump and then parse the data later using wireshark. This is especially nice when you may not be able wireshark on the device where you want to capture the data (i.e. a headless server). For example:

sudo tcpdump -w /tmp/capture_data -s 8192 port 8000

Alternately, if you have control over the WebSockets server (or proxy) you could always print out the send and receive data. Note that since websocket frames start with '\x00' will want to avoid printing that since in many languages '\x00' means the end of the string.

芯好空 2024-10-04 03:50:27

如果您正在寻找发送和接收的实际数据,最近的 Chrome Canary 和 Chromium 现在具有 WebSocket 消息帧检查功能。
您可以在此帖子中找到详细信息。

If you're looking for the actual data sent and received, the recent Chrome Canary and Chromium have now WebSocket message frame inspection feature.
You find details in this thread.

我是男神闪亮亮 2024-10-04 03:50:27

我认为你应该使用Wireshark

步骤

  • 打开wireshark
  • Go来捕获并遵循以下路径:捕获>接口>在适当的设备中开始捕获。
  • 在过滤器中写入规则 tcp.dstport == your_websoket_port
  • 点击应用

I think you should use Wireshark

Steps

  • Open wireshark
  • Go to capture and follow bellow path: capture > interfaces > start capture in your appropriate device.
  • Write rules in filter tcp.dstport == your_websoket_port
  • Hit apply
や莫失莫忘 2024-10-04 03:50:27

对于简单的事情来说,wireshark太复杂了,我只想检查是否可以建立连接。遵循 Chrome 插件“简单 Web-socket”(链接:https ://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo?hl=en)”就像魅力一样。参见图片。

https://lh3.googleusercontent.com/bEHoKg3ijfjaE8- RWTONDBZolc3tP2mLbyWanolCfLmpTHUyYPMSD5I4hKBfi81D2hVpVH_BfQ=w640-h400- e365

For simple thing, wireshark is too complex, i wanted to check only if the connection can be establish or not. Following Chrome plugin "Simple Web-socket (link : https://chrome.google.com/webstore/detail/simple-websocket-client/pfdhoblngboilpfeibdedpjgfnlcodoo?hl=en)" work like charm. See image.

https://lh3.googleusercontent.com/bEHoKg3ijfjaE8-RWTONDBZolc3tP2mLbyWanolCfLmpTHUyYPMSD5I4hKBfi81D2hVpVH_BfQ=w640-h400-e365

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文