带有 nodejs 的 Pusher 在代理网络下无法工作
Pusher with nodejs not work under proxy network
我按照 Pusher JS is not working from node JS in some network 的指南在我的代码中设置代理。但是,它在我的终端中显示错误。
以下是我添加代理服务器的代码
var Pusher = require("pusher");
var pusher = new Pusher({
appId: config.app_id,
key: config.key,
secret: config.secret,
proxy: 'http://username:password@proxynework:ppr\#',
timeout: TIMEOUT,
keepAlive: KEEP_ALIVE
});
问题是变量 TIMEOUT
没有在任何地方设置(KEEP_ALIVE
也会有同样的问题)。您有几个选项可以解决此问题:
1) 设置超时和keepAlive
//...
proxy: 'http://username:password@proxynework:ppr\#',
timeout: 2000,
keepAlive: false
2) 将它们排除在外(它们是可选的)
// ...
proxy: 'http://username:password@proxynework:ppr\#'
// use default timeout and keepalive values
});
我按照 Pusher JS is not working from node JS in some network 的指南在我的代码中设置代理。但是,它在我的终端中显示错误。
以下是我添加代理服务器的代码
var Pusher = require("pusher");
var pusher = new Pusher({
appId: config.app_id,
key: config.key,
secret: config.secret,
proxy: 'http://username:password@proxynework:ppr\#',
timeout: TIMEOUT,
keepAlive: KEEP_ALIVE
});
问题是变量 TIMEOUT
没有在任何地方设置(KEEP_ALIVE
也会有同样的问题)。您有几个选项可以解决此问题:
1) 设置超时和keepAlive
//...
proxy: 'http://username:password@proxynework:ppr\#',
timeout: 2000,
keepAlive: false
2) 将它们排除在外(它们是可选的)
// ...
proxy: 'http://username:password@proxynework:ppr\#'
// use default timeout and keepalive values
});