gpt4 book ai didi

node.js - 在 NodeJS 中调试 websockets

转载 作者:行者123 更新时间:2023-12-02 03:35:30 50 4
gpt4 key购买 nike

我想检查/调试使用 websockets 的 NodeJS 应用程序的网络流量。我没有看到通过像 Fiddler 这样的代理重定向应用程序的 websocket 流量的明显方法(应用程序使用 ws package )。 Wireshark 是我唯一的选择吗?不得不在树中向下钻取以找到每个数据包的未屏蔽文本是一种痛苦。使用“Follow TCP Stream ”几乎是我想要的,但是传出的文本被屏蔽了,并且每条消息旁边都有一个时间戳会很好。

最佳答案

不完全确定您在寻找什么,但您可以将其包含在您的 app.js 中

var debug = require('debug')('my-application');
app.set('port', process.env.PORT || 3132);

var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});

这在你的 package.json 中
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"express": "~4.0.0",
....

以上允许我调试我的套接字......但不确定这是否是你所得到的

关于node.js - 在 NodeJS 中调试 websockets,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23691644/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com