调试NodeJS中的websockets

时间:2014-05-16 02:20:23

标签: node.js debugging websocket wireshark

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

2 个答案:

答案 0 :(得分:0)

不完全确定您要查找的内容,但您可以将其添加到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",
 ....

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

答案 1 :(得分:0)

尽管这个问题已经花了很长时间,但是看来Microsoft的Visual Studio Code可以回答这个问题。 https://code.visualstudio.com/docs/nodejs/nodejs-debugging。有一天可能会帮助某人。