I am using nodejs and passportjs-twitter to make the twitter authentication into my website,but when I start the process,I always get the error as below:
Error: connect ETIMEDOUT at Strategy.OAuthStrategy._createOAuthError
I read the passportjs-twitter for many times and read many examples on the Internet,I found they are coded in the same style as what I do in my code and I don't know the reason of it,but I am always got the error, can anyone help me to analysis it?Below are the relevant code block:
var twitter_consumerKey='******',
var twitter_consumerSecret='*************',
var twitter_callbackURL='http://127.0.0.1:8000/auth/twitter/callback',
app.get('/auth/twitter',site.logInTwitter);
app.get('/auth/twitter/callback',site.logInTwitterCallback);
var passport=require('passport');
var TwitterStrategy = require('passport-twitter').Strategy;
exports.logInTwitter=passport.authenticate('twitter');
exports.logInFacebook=passport.authenticate('facebook');
exports.logInTwitterCallback=function(req,res,next){
passport.authenticate('twitter',function(err,info){
if(err){
//return next(err);
console.log("===========ifeng====================",err);
return res.render("templates/logInPage",info);
}
return res.render("templates/logInPage",info)
})(req,res.next);
}
passport.use(new TwitterStrategy({
consumerKey:twitter_consumerKey,
consumerSecret:twitter_consumerSecret,
callbackURL:twitter_callbackURL
},function(token,tokenSecret,profile,done){
console.log("======token:\t",token);
//console.log(profile);
return done(null,null);
}));
passport.serializeUser(function(user,done){
done(null,user);
});
passport.deserializeUser(function(user,done){
done(null,user);
});
Now when I start the authentication process I alway got the error stack as below,I can not even get the twitter login page,can anyone help me to analysis it,thanks in advance!
Error: connect ETIMEDOUT
at Strategy.OAuthStrategy._createOAuthError (D:\code\nodejsWorkspace\andy\node_modules\passport-twitter\node_modules\passport-oauth1\lib\strategy.js:352:17)
at D:\code\nodejsWorkspace\andy\node_modules\passport-twitter\node_modules\passport-oauth1\lib\strategy.js:218:41
at D:\code\nodejsWorkspace\andy\node_modules\passport-twitter\node_modules\passport-oauth1\node_modules\oauth\lib\oauth.js:543:17
at ClientRequest.<anonymous> (D:\code\nodejsWorkspace\andy\node_modules\passport-twitter\node_modules\passport-oauth1\node_modules\oauth\lib\oauth.js:421:9)
at ClientRequest.emit (events.js:95:17)
at CleartextStream.socketErrorListener (http.js:1547:9)
at CleartextStream.emit (events.js:95:17)
at Socket.onerror (tls.js:1440:17)
at Socket.emit (events.js:117:20)
at net.js:440:14