使用Chrome开发者工具,web socket应用的调试显得异常方便。
打开Chrome开发者工具,切换到network标签页,选择Filter,根据WS过滤,
刷新我们的web socket应用,回到开发者工具,马上就能看到对应的记录了:
https://blog.csdn.net/i042416/article/details/87891099
Chrome远程调试之WebSocket
var ws = new WebSocket(‘ws://localhost:9222/devtools/page/3c5c05fa-80b7-4cfe-8d1d-ebe79a7a5730’);
ws.onopen= function() {
ws.send(‘{“id”: 1, “method”: “Page.navigate”, “params”: {“url”: “https://www.fangdushi.com”}}’)
};
ws.onmessage= function(evt) {
console.log(‘Received a message from the server!’+evt.data);
};
api文档地址https://chromedevtools.github.io/devtools-protocol/1-2
https://www.cnblogs.com/zhuyeshen/p/12004998.html
https://www.zhihu.com/question/33872126