I have developed an API using node.js. In my local system API is running at port 2100, and i used the following curl command
curl -i -H "Content-Type: application/json" -X GET http://localhost:2100/xx/yy/zzz
And i received the following response:
HTTP/1.1 401 Unauthorized X-Powered-By: Express Vary: Accept-Encoding WWW-Authenticate: Bearer realm="Users" Set-Cookie: connect.sid=s%3A-qD8JTJTLNTnbc0bv2YsTcd2.sfJK8%2FOFan26l8QhuS4oxyEvUtGvhztevEcWX51kceE; Path=/; HttpOnly Date: Wed, 06 May 2015 09:31:30 GMT Connection: keep-alive Transfer-Encoding: chunked
Because i am using authorization i received the above response.
But in my production system i used the same curl command but i am receiving
curl: (52) Empty reply from server
I dont know whats happening? I searched a lot but i cant find a solution. Please share your ideas.
EDIT:
MY API has crashed due to this error:
Exception: Error setting TTL index on collection : sessions",
MY code:
app.use(express.session({
secret: 'MEAN',
store: new mongoStore({
url: config.dbmongo.db,//db
collection: 'sessions'
})
}));
Can you please explain what i am doing wrong?
You should be start listening after the db is connected. It might possibly be the issue.
Answer from github
mongoose.connect.on('connected', function () {
var server = app.listen(app.get('port')), function () {
debug('Express server listening on port %d in mode %s', server.address().port, app.get('env'));
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.