ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 206 forks source link

Error: tunneling socket could not be established #165

Closed sunojvijayan closed 8 years ago

sunojvijayan commented 8 years ago

Hi,

I tried working on this from my local machine with my gcm credentials but got this error.

{ [Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND 8080 8080:80] code: 'ECONNRESET' }

Can anyone help please?

hypesystem commented 8 years ago

This is not an error I have seen before. How does your code look?

eladnava commented 8 years ago

@sunojvijayan It's DNS related, a code snippet will help us understand the problem.

sunojvijayan commented 8 years ago

This is my code.

var gcm = require('node-gcm');
var message = new gcm.Message();

//API Server Key
var sender = new gcm.Sender('sender id here', {
    'proxy': 'aaa.abcd.com.my:8080'
});
var registrationIds = [];

// Value the payload data to send...
message.addData('message', "\u270C Peace, Love \u2764 and PhoneGap \u2706!");
message.addData('title', 'Push Notification Sample');
message.addData('msgcnt', '3'); // Shows up in the notification in the status bar
message.addData('soundname', 'beep.wav'); //Sound to play upon notification receipt - put in the www folder in app
//message.collapseKey = 'demo';
//message.delayWhileIdle = true; //Default is false
message.timeToLive = 3000; // Duration in seconds to hold in GCM and retry before timing out. Default 4 weeks (2,419,200 seconds) if not specified.

// At least one reg id required
registrationIds.push('registration id of my device');

/**
 * Parameters: message-literal, registrationIds-array, No. of retries, callback-function
 */
sender.send(message, registrationIds, 4, function (result) {
    console.log(result);
});
console.log("Sending");
sunojvijayan commented 8 years ago

I copied it directly from the site

eladnava commented 8 years ago

@sunojvijayan I'd guess that your proxy server is not working as expected:

var sender = new gcm.Sender('sender id here', {
'proxy': 'intproxy01.maybank.com.my:8080'
});

tunneling socket could not be established most likely refers to the proxy tunnel.

hypesystem commented 8 years ago

We have previously had this issue #97

A PR was started but never completed #115

sunojvijayan commented 8 years ago

I have removed the proxy and now getting this error

{ [Error: tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:80] code: 'ECONNRESET' }

sunojvijayan commented 8 years ago

Please help

hypesystem commented 8 years ago

Have you changed any of the code inside the node-gcm module? It should be connecting to gcm-http.googleapis.com, not 127.0.0.1 as it does in your case.

eladnava commented 8 years ago

@hypesystem @sunojvijayan maybe the http_proxy ENV variable is set?

hypesystem commented 8 years ago

I am leaning towards something like that. Anything that modifies the underlying behaviour of request could result in this.

sunojvijayan commented 8 years ago

I have not modified any code inside node-gcm module

sunojvijayan commented 8 years ago

But when I searched the code it has two files cosmic.js and usage.js in which 127.0.0.1 is mentioned.

eladnava commented 8 years ago

@sunojvijayan what we mean is that you may have set the http_proxy environment variable (outside of the node script, as an OS env variable).

Try the following command (in Linux) to check if you set it by accident:

printenv http_proxy

hypesystem commented 8 years ago

As you can see here the phrase "127.0.0.1" does not appear anywhere inside node-gcm. You may have some other library interfering.

sunojvijayan commented 8 years ago

Oh sorry everyone proxy was enabled for npm. It works now thanks a lot everyone

sunojvijayan commented 8 years ago

But is there a way I can run this behind a proxy?

eladnava commented 8 years ago

@sunojvijayan there seems to be an issue with that currently: #97

hypesystem commented 8 years ago

We really should solve the proxy problem -- but that's not this issue. Closing it :smile: please continue discussion about proxy use on #97.

sunojvijayan commented 8 years ago

ok thanks