Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidServerResponse #16

Closed
gfosco opened this issue May 2, 2012 · 7 comments
Closed

InvalidServerResponse #16

gfosco opened this issue May 2, 2012 · 7 comments

Comments

@gfosco
Copy link

gfosco commented May 2, 2012

Thanks for your work on this module! I have a question... I've implemented this and it seems to work fine for a while, then stops. I get an error of InvalidServerResponse. This is just for a few test devices in-house so I know the registration id's are valid.

Any idea why this might occur? I've just added a console.log statement to the respond() function where this error code is set, and will report back.

@gfosco
Copy link
Author

gfosco commented May 2, 2012

I get an HTML page with a 401 Unauthorized response. Perhaps the module could detect this and re-connect? I've set keepAlive to true and it's still happening.

@morettoni
Copy link

I get the same problem yesterday, but reading the documentation at https://github.com/SpeCT/node-c2dm#avoiding-login-procedure is better to handle the update of auth token with:

c2dm.on('token', function(err, token) { ... });

this fix for me!

@antonsson
Copy link

Hi,

I have also this problem and I might found the reason why. Comparing the message sent before and after the Update-client-auth is received there is a difference in the token.

{"host":"android.apis.google.com","port":443,"path":"/c2dm/send","method":"POST","headers":{"Host":"android.apis.google.com","Authorization":"GoogleLogin Auth=DQAAAL4AAABt92s...etc"}}

And after a token update it is sent like this

{"host":"android.apis.google.com","port":443,"path":"/c2dm/send","method":"POST","headers":{"Host":"android.apis.google.com","Authorization":"GoogleLogin DQAAAL0AAAB...etc"}}

Second one is missing the Auth= in the GoogleLogin, so I just changed in the c2dm.js file to add 'auth=' when saving the new token and it seems to work better. Need to do some more testing though.

@morettoni
Copy link

antonsson could you share your changes? Just to be sure, I'm moving my first steps on JavaScript and Node.js world!

@antonsson
Copy link

For me as well, working on my first node js project, so I can't guarentee anything :)

Here are my changes, starting at line 118.

            // Check if we need to update the headers and try again
            var newToken = res.headers['update-client-auth'];
            if (newToken) {
                self.emit('token', null, "Auth="+newToken);
                // Removed two lines below as the answer is still available in this response, no need to send again.
                //self.send(packet, cb);
                //return; // ignore any other events from this request
            }

So far it is working for me at least

Edit: Probably the correct way is to look for the Auth and add it only if it is missing according to above

@charlesdaniel
Copy link
Contributor

It'd be really cool if one of the pull requests to fix this InvalidServerResponse could get merged in and pushed out to npm. It seemed to fix the errors I was getting with InvalidServerResponse.

@SpeCT
Copy link
Owner

SpeCT commented Oct 28, 2012

Hi Guys.
I'm not sure is it still actual for you, but I've merged @charlesdaniel's patch into the master and uploaded new version to npm.
PS: Thanks to isaak for support urls in dependencies section. I so miss this feature in kanso ;)

@SpeCT SpeCT closed this as completed Oct 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants