无法在 Charles [mac] 中看到 http 流量 from/to 我的 NodeJS 应用程序
Unable to see http traffic from/to my NodeJS app in Charles [mac]
我是 运行 Charles,负责在我的机器上 运行 本地检查节点 js 客户端和服务之间的 HTTP 流量 (Mac)。我可以访问该服务,但在 Charles 中看不到任何痕迹。我已经尝试用我机器的 IP 名称替换 localhost 但仍然没有踪迹。如果我在 Chrome 中键入服务 URL,我确实会看到一条痕迹。有人知道如何解决这个问题吗?
这是我的 nodejs 代码:
var thrift = require('thrift'); // I use Apache Thrift
var myService = require('./gen-nodejs/MyService'); // this is code generated by thrift compiler
var transport = thrift.TBufferedTransport();
var protocol = thrift.TBinaryProtocol();
var connection = thrift.createHttpConnection("localhost", 5331, {
transport : transport,
protocol : protocol,
path: '/myhandler',
});
connection.on('error', function(err) {
console.log(err);
});
// Create a client with the connection
var client = thrift.createHttpClient(myService, connection);
console.log('calling getTotalJobCount...');
client.getTotalJobCount(function(count)
{
console.log('total job count = ' + count);
});
和我的代理设置:
在 this link 的帮助下自己解决了这个问题。 Charles 拦截了通过我 mac 上的 127.0.0.1:8888
系统代理的流量。这是正确的代码:
// give path to the proxy in argument to createHttpConnection
var connection = thrift.createHttpConnection('127.0.0.1', 8888, {
transport : transport,
protocol : protocol,
path: 'http://localhost:5331/myhandler', // give the actual URL you want to connect to here
});
另外需要用thrift.TBufferedTransport
代替thrift.TBufferedTransport()
和thrift.TBinaryProtocol
代替thrift.TBinaryProtocol()
我是 运行 Charles,负责在我的机器上 运行 本地检查节点 js 客户端和服务之间的 HTTP 流量 (Mac)。我可以访问该服务,但在 Charles 中看不到任何痕迹。我已经尝试用我机器的 IP 名称替换 localhost 但仍然没有踪迹。如果我在 Chrome 中键入服务 URL,我确实会看到一条痕迹。有人知道如何解决这个问题吗?
这是我的 nodejs 代码:
var thrift = require('thrift'); // I use Apache Thrift
var myService = require('./gen-nodejs/MyService'); // this is code generated by thrift compiler
var transport = thrift.TBufferedTransport();
var protocol = thrift.TBinaryProtocol();
var connection = thrift.createHttpConnection("localhost", 5331, {
transport : transport,
protocol : protocol,
path: '/myhandler',
});
connection.on('error', function(err) {
console.log(err);
});
// Create a client with the connection
var client = thrift.createHttpClient(myService, connection);
console.log('calling getTotalJobCount...');
client.getTotalJobCount(function(count)
{
console.log('total job count = ' + count);
});
和我的代理设置:
在 this link 的帮助下自己解决了这个问题。 Charles 拦截了通过我 mac 上的 127.0.0.1:8888
系统代理的流量。这是正确的代码:
// give path to the proxy in argument to createHttpConnection
var connection = thrift.createHttpConnection('127.0.0.1', 8888, {
transport : transport,
protocol : protocol,
path: 'http://localhost:5331/myhandler', // give the actual URL you want to connect to here
});
另外需要用thrift.TBufferedTransport
代替thrift.TBufferedTransport()
和thrift.TBinaryProtocol
代替thrift.TBinaryProtocol()