bnoguchi / everyauth

node.js auth package (password, facebook, & more) for Connect and Express apps
http://everyauth.com/
3.49k stars 447 forks source link

Facebook Connect Times-out? #58

Open felixchan opened 13 years ago

felixchan commented 13 years ago

I'm using everyauth v 0.2.2

Step getAccessToken of `facebook` module timed out.
Error: Step getAccessToken of `facebook` module timed out.
    at /home/user/project/node_modules/everyauth/lib/step.js:101:18
    at Object.<anonymous> (/home/user/project/node_modules/everyauth/lib/promise.js:63:27)
    at Timer.callback (timers.js:83:39)

I restarted my node app.js, and then it worked. After playing with it (logging in/ logging out), it would time out again until i restart the node app.

I did this on 3 servers (identical EC2 images of each other), and they all had the same result. (In other words, after logging in/out for many times, it times out until I restart the server)

Any help? thanks a lot!

felixchan commented 13 years ago

I set moduleTimeout to 999999999.

But it still seems to be hanging. (it just doesn't throw an error anymore)

emilioastarita commented 13 years ago

I'm seeing the same error. Is very annoying, because I must restart a production server. I can't reproduce the error in my development environment.

ElliotChong commented 12 years ago

I can also confirm this occurring- rebooting the server fixes the issue.

diversario commented 12 years ago

I started testing my app and this error doesn't let me past the login step.

emilioastarita commented 12 years ago

news?

saschagehlich commented 12 years ago

+1

Felixaverlant commented 12 years ago

same here

felixchan commented 12 years ago

If you set:

moduleTimeout to 999999999

Everything will work. It just takes a longer time sometimes.

emilioastarita commented 12 years ago

@felixchan not in my case. When this problem occurs I must to restart the server because nobody can do login anymore until restart.

Felixaverlant commented 12 years ago

Maybe it's my cheap home server, it doesn't work for me if 2 users refresh at the same time the web page ... I switched to connect-auth, hope I'll don't get the same !

Thanks for you help

saschagehlich commented 12 years ago

@bnoguchi any updates on that one?

goldfire commented 12 years ago

Any update sont his? I just run into this same problem 7 days before we go live.

bnoguchi commented 12 years ago

I'm shipping a new version of everyauth this week, so hopefully we can resolve this issue in the new release. I want to reproduce this issue, first. Can you provide a gist and additional information for reproducing the issue?

On Tue, Feb 28, 2012 at 7:08 AM, James Simpson < reply@reply.github.com

wrote:

Any update sont his? I just run into this same problem 7 days before we go live.


Reply to this email directly or view it on GitHub: https://github.com/bnoguchi/everyauth/issues/58#issuecomment-4217492

dezmozz commented 12 years ago

+1

giacecco commented 12 years ago

Same problem here after upgrading to everyauth 0.2.32, but it is likely unrelated to the exact version, as I've tried downgrading down to every version down to 0.2.28 with no improvement. 'Restarting the server' does not change anything.

I've been using Facebook Connect via everyauth without any issues since 2 March, and I keep using everyauth successfully with Twitter and GitHub.

Now, with Facebook, when trying authenticating I get:

timers.js:96
            if (!process.listeners('uncaughtException').length) throw e;
                                                                      ^
Error: Step getAccessToken of `facebook` module timed out.
    at /Users/giacecco/Documents/Projects/giaceccosdci/projects/Mazulio/eclipse-workspace/Mazulio/node_modules/everyauth/lib/step.js:121:18
    at Object.<anonymous> (/Users/giacecco/Documents/Projects/giaceccosdci/projects/Mazulio/eclipse-workspace/Mazulio/node_modules/everyauth/lib/promise.js:65:27)
    at Timer.ontimeout (timers.js:94:19)

If instead I set moduleTimeout to 999999999, what I get after a while is:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: socket hang up
    at createHangUpError (http.js:1107:15)
    at CleartextStream.<anonymous> (http.js:1210:27)
    at CleartextStream.emit (events.js:88:20)
    at Array.0 (tls.js:792:22)
    at EventEmitter._tickCallback (node.js:192:40)

Please help!

G.

ElliotChong commented 12 years ago

+1

greenimpala commented 12 years ago

+1 happening regardless of how long moduleTimeout is set to. I'm suspecting this may be an issue with Facebook as, in my case, it works about 80% of the time.

krampstudio commented 12 years ago

got the same but with twitter's getRequestToken

giacecco commented 12 years ago

krampstudio: Twitter is working nicely to me, it is likely your problem is different.

giacecco commented 12 years ago

I'm starting getting worried by bnoguchi's silence.

Bnoguchi please let us know at least what you think about the issue we're having: is it an everyauth issue or we are doing something wrong, also considering how - at least in my case - everything was working nicely until two weeks ago?

Thanks!

kaij commented 12 years ago

I have the same problem and started some debugging. I think it depends on the version of OpenSSL that node is using.

Using OpenSSL 1.0.1, the simple command openssl s_client -connect graph.facebook.com:443 fails on connect. But: openssl s_client -connect graph.facebook.com:443 -tls1 will work right away. I read somewhere that newer versions of OpenSSL will use TLS 1.2 by default. I therefore think it's either a bug in openssl TLS 1.2 handshake or on facebook's server not being capable of handling TLS 1.2 handshakes. Because the TLS 1.2 handshake works if you try it just after the tls1, I suspect the latter.

You can check the openssl version with node -e 'console.error(process.versions)'

I'm using OS X 10.7.3. Testing the default connect with OpenSSL 0.9.8r, everything works as expected.

Update after some more research I found this: http://rt.openssl.org/Ticket/Display.html?id=2771. So it is an OpenSSL bug, which may also affect older versions. For this specific case, I solved the problem by linking nodejs to OpenSSL v1.0.0g.

CCVonLewin commented 12 years ago

excuse my ignorance but how do you "link" nodejs to use OpenSSL v1.0.0g?

kaij commented 12 years ago

Depends on system. OS X: install openssl 1.0.0g (system). Then rebuild node from source (configure, make, make install).

benbuckman commented 12 years ago

I'm seeing this problem too,

 Error: Step getAccessToken of `google` module timed out.
     at app/node_modules/everyauth/lib/step.js:121:18
     at Object.<anonymous> (app/node_modules/everyauth/lib/promise.js:65:27)
     at Timer.ontimeout (timers.js:84:39)

Is OpenSSL definitely the issue here? It seems like everyauth should at least handle this more gracefully.

kaij commented 12 years ago

You can check if openssl/tls1.2 handshake is causing the problem in your case (replace the url with the different SSL endpoints, use graph.facebook.com for fb):

$ openssl version
OpenSSL 1.0.1 14 Mar 2012
$ openssl s_client -msg -connect www.googleapis.com:443

If connection is successful with OpenSSL 1.0.1 you will get

New, TLSv1/SSLv3, Cipher is ECDHE-RSA-RC4-SHA

If above does not work (you just get a connected status message), try

$ openssl s_client -tls1 -msg -connect graph.facebook.com:443

If both works, I suggest to increase the timeout and specify detailed parameters, e.g. like this (fb):

everyauth.facebook
      .myHostname('http://localhost:3000')
      .accessTokenHttpMethod('get')
      .postAccessTokenParamsVia('query')
      .appId(common.facebook.appId)
      .appSecret(common.facebook.appSecret)
      .scope('email')
      .moduleTimeout(20000)
shivsood commented 12 years ago

I am using openssl 0.9.8r on Ubuntu 10.10. I still keeping getting this issue.

openssl s_client -tls1 -msg -connect graph.facebook.com:443 and openssl s_client -msg -connect graph.facebook.com:443 fail on my system.

Is there a way out??

imers.js:96
            if (!process.listeners('uncaughtException').length) throw e;                                                                      ^
Error: Step getAccessToken of `facebook` module timed out.
    at /home/shiv/node_modules/everyauth/lib/step.js:121:18
    at Object.<anonymous> (/home/shiv/node_modules/everyauth/lib/promise.js:65:27)
    at Timer.ontimeout (timers.js:94:19)
strada commented 12 years ago

I'm also getting the error:

Error: Step getAccessToken of `foursquare` module timed out.

when I try to implement a Foursquare login for an app. Removing the timeout did not help.

bnoguchi commented 12 years ago

@strada Can you provide instructions about how to re-produce this on localhost, along with a gist?

Brian

strada commented 12 years ago

@bnoguchi Here it is: https://gist.github.com/2462626

strada commented 12 years ago

@bnoguchi My mistake with the foursquare login, I was redirecting the user to the app authentication url as described in the Foursquare documentation. It works if I redirect the user to /auth/foursquare/.

daskalov commented 12 years ago

I just ran into this same issue in production. everyauth was working fine locally and on another production server. The issue did turn out to be OpenSSL. Thanks @kaij

Confirmed working: 0.9.8b, 0.9.8l, 0.9.8o

Hits a timeout when authenticating with Facebook (through mongoose-auth): 1.0.1

jgallen23 commented 12 years ago

I'm having the same issue with OpenSSL 0.9.8o (Ubuntu 11.04). I extended the timeout period, but I still get timeout errors. It doesn't happen all the time, but once it starts happening, it keeps failing

CCVonLewin commented 12 years ago

i also encountered [ ... 'facebook' module timed out. ], w/ OpenSSL 0.9.8o + Ubuntu 11.04, which in turn crashed my app. @kaij provided excellent details on the specific problem, which is NOT a fault of the everyauth module built by @bnoguchi.

The resolution offered seems to have worked for me for the past several days. I updated Ubuntu to 11.10 and now am using OpenSSL 1.0.0e. I also added some addtional methods to the [ everyauth.facebook ] class as suggested w/in my node app.js:

...
everyauth.facebook
    .myHostname(CONFIG.authentication.facebook.hostname)
    .accessTokenHttpMethod('get')
    .postAccessTokenParamsVia('query')
    .appId(CONFIG.authentication.facebook.appId)
    .appSecret(CONFIG.authentication.facebook.appSecret)
    .moduleTimeout(60000)
    .findOrCreateUser( function (session, accessToken, accessTokenExtra, fbUserMetadata) {
            console.log( "AUTH --- [facebook] id: " + fbUserMetadata.id);
            return usersByFbId[fbUserMetadata.id] || (usersByFbId[fbUserMetadata.id] = addUser('facebook', fbUserMetadata));
    })
    .redirectPath("/#!/client/facebook/");
...

Before doing the above 3 things i was very frustrated that this module did not have a graceful method for dealing w/ errors. Then it dawned on me after a suggestion by another developer that frankly it really doesnt need to (which is debatable). One can achieve catching the error via 2 means;

http://nodejs.org/api/process.html#process_event_uncaughtexception "Emitted when an exception bubbles all the way back to the event loop. If a listener is added for this exception, the default action (which is to print a stack trace and exit) will not occur."

I use Express and found the following:

http://stackoverflow.com/questions/10221309/use-process-onuncaughtexception-to-show-a-500-error-page http://expressjs.com/guide.html#error-handling

With Express via [ app.error(); ] I in theory could catch the error tossed by the time out and send the user to an error page w/o crashing that app. The code i have implemented is below. Unfortunately, i have not been able to test it or see it in action since i had already updated the os and openssl but in theroy it should help stem app crashes w/ time outs and other odd errors tossed by everyauth.

...
// config
app.configure ...

// error hnadler
app.error( function ( error, request, response ) {
        // debug: write info to shell running app
        console.log( "### ERROR --- ERROR --- ERROR --- ERROR ###" );

        // respond
        response.render(
            "exception",
            { message: { error: JSON.stringify( error ) } }
        );
});

// route handler
app.get(...)
...
jgallen23 commented 12 years ago

I have the app.error handler set up, but for some reason the page still hangs when the timeout happens. For me it hits process.on('uncaughtException' instead of app.error

I'm on Ubuntu 12.04 now with OpenSSL 1.0.1 and the timeout still happens occasionally

kivikakk commented 12 years ago

Also get this. It's trivial to test by just setting an invalid code in the callback. process.on('uncaughtException', function(err) { ... }) does catch it, but of course you can't give anything to the user with this. :|

liorgrossman commented 12 years ago

I'm getting Error: Step getAccessToken of 'facebook' module timed out 80% of the time! I tried creating 4 different AWS EC2 machines from scratch (Ubuntu, CentOS, with OpenSSL 0.9.8/1.0/1.1). Keeps on happening. (This doesn't happen on my Win 7 machine, though.)

Inside 'oauth2.js', on the getAccessToken() function, there is a call:

   rest[this._accessTokenHttpMethod](url, opts)
      .on('success', function (data, res) {...
      }).on('error', function (data, res) {...
      });

This call simply doesn't return. Neither 'success' nor 'error' are called :-/

Here are the parameters passed to "rest": this._accessTokenHttpMethod = 'get' url = 'https://graph.facebook.com/oauth/access_token' opts = { query: { client_id: '319366648181826', redirect_uri: 'http://www.passionly.com/auth/facebook/callback', code: 'AQD2bz16SfDUELGzitOCpetKiaaGKARGAkiVD...', client_secret: 'c149a90d81cf8cca1a45...' }, headers: { 'Content-Length': 0 } }

I've spend the last 24h trying to solve this. Why doesn't the access_token rest call return?

liorgrossman commented 12 years ago

Update: tried it with Ubuntu 8.1 (native OpenSSL 0.9.8), tried it on EC2 and on Rackspace Cloud. Still getting getAccessToken of 'facebook' module timed out, 80% of the time. This is clearly not related to the platform or operating system. What could it be?

liorgrossman commented 12 years ago

Finally, I found the source of the timeout problem. It's caused by the new version of restler module installed with Everyauth.

Everyauth package.json states it depends on: "restler": ">=0.2.1" Therefore, everyauth installs with the newest version: restler 2.0.1 I managed to solve the timeout issues by uninstalling restler@2.0.1, and manually installing an older version: restler@0.2.1

The best way to avoid this problem in the first place, is to install restler@0.2.1 before installing everyauth. If you encounter this issue on your existing everyauth installation - try deleting the directory /node_modules/everyauth/node_modules/restler and then running "npm install restler@0.2.1" in your application directory

@bnoguchi - this is a major issue, I suggest you update package.json

wlzch commented 12 years ago

+1 for liorgrossman solution. It is working now.

adamsch1 commented 12 years ago

liorgrossman -

I too have encountered this problem. I tried following liorgrossman's solution:

npm restler@0.2.1

Then install the latest everyauth.

Now I get an exception:

/home/shane/slurp/node_modules/everyauth/lib/modules/google.js:47 return new Error(data.data.match(/H1>(.+)<\/H1/)[1]); ^ TypeError: Cannot call method 'match' of undefined at /home/shane/slurp/node_modules/everyauth/lib/modules/google.js:47:32 at /home/shane/slurp/node_modules/everyauth/lib/step.js:97:21

adamsch1 commented 12 years ago

Seems that the data parameter has changed somewhat so the regex used to match it fails. There is a valid error in data however, and this led me to realize my redirectUrl was not set. I do not know what standards you use for creating an error exception, otherwise I would apply a patch.

.convertErr( function (data) { console.log("%j",data); return new Error("shit");//data); })

PS liorgrossman fix does fix the timeout isue however!