问题
I followed the guide of Pusher docs to create a simple example, and the code is copy from the Code examples.
This example works well when I'm at home, but it's never working when I'm in office.
In office, the HTML page can alert the message when I use the Debug Console provided by Pusher to create new Event. However, the HTML page won't alert any messages when I trigger the event from node JS.
I guess the problem is related to the network, so I want to know how to jump over the network limitation while using pusher js from node js.
回答1:
var pusher = new Pusher({ // you can set other options in any of the 3 ways described above
proxy: 'HTTP_PROXY_URL', // optional, URL to proxy the requests through
timeout: TIMEOUT, // optional, timeout for all requests in milliseconds
keepAlive: KEEP_ALIVE // optional, enables keep-alive, defaults to false
});
The issue has been solved, it indeed is the network matters, and just set the proxy, then it works.
来源:https://stackoverflow.com/questions/26707546/pusher-js-is-not-working-from-node-js-in-some-network