在 Google Chrome 中调试 WebSocket [英] Debugging WebSocket in Google Chrome

查看:183
本文介绍了在 Google Chrome 中调试 WebSocket的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法或扩展可以让我观看通过 WebSocket 的流量"?出于调试目的,我想查看客户端和服务器的请求/响应.

Is there a way, or an extension, that lets me watch the "traffic" going through a WebSocket? For debugging purposes I'd like to see the client and server requests/responses.

推荐答案

Chrome 开发人员工具现在可以列出 WebSocket 帧,如果帧不是二进制的,还可以检查数据.

Chrome developer tools now have the ability to list WebSocket frames and also inspect the data if the frames are not binary.

过程:

  1. 启动 Chrome 开发者工具
  2. 加载您的页面并启动 WebSocket 连接
  3. 点击网络标签.
  4. 从左侧的列表中选择 WebSocket 连接(状态为101 Switching Protocols".
  5. 点击消息子标签.二进制帧将显示长度和时间戳,并指示它们是否被屏蔽.文本框也将显示包含负载内容.
  1. Launch Chrome Developer tools
  2. Load your page and initiate the WebSocket connections
  3. Click the Network Tab.
  4. Select the WebSocket connection from the list on the left (it will have status of "101 Switching Protocols".
  5. Click the Messages sub-tab. Binary frames will show up with a length and time-stamp and indicate whether they are masked. Text frames will show also include the payload content.

如果您的 WebSocket 连接使用二进制帧,那么您可能仍希望使用 Wireshark 来调试连接.Wireshark 1.8.0 添加了对 WebSocket 的解析器和过滤支持.可以在此其他答案中找到替代方法.

If your WebSocket connection uses binary frames then you will probably still want to use Wireshark to debug the connection. Wireshark 1.8.0 added dissector and filtering support for WebSockets. An alternative may be found in this other answer.

这篇关于在 Google Chrome 中调试 WebSocket的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆