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

request hangs somehow #24

Closed
Ognian opened this issue Oct 15, 2014 · 4 comments
Closed

request hangs somehow #24

Ognian opened this issue Oct 15, 2014 · 4 comments

Comments

@Ognian
Copy link

Ognian commented Oct 15, 2014

Starting this trivial static file sever:

var express = require('express'),
    app = express(),
    http = require('http'),
    server = http.createServer(app)
    ;
var morgan = require('morgan');
app.use(morgan('dev')); //this is the express logger...
app.use(require('errorhandler')({dumpExceptions: true, showStack: true}));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// HERE comes the problem:
var session = require('express-session');
var MongoHttpSessionStore = require('connect-mongostore')(session);

var cookieParser = require('cookie-parser');
app.use(cookieParser());

app.use(session({
        secret: "x",
        store: new MongoHttpSessionStore(
            {
                collection: "_sTEST_delete",
                db: "test"
            }
        ),
        cookie: {
            maxAge: 60000 * 30
        }, // in minute(s) from milliseconds-> *60000
        // the following are both default true
        resave: true,
        saveUninitialized: true
    }
));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
app.use('/', express.static(__dirname + '/public')); //at last try to find if this is a static file...
server.listen(3005);
console.log("started on port 3005");

and testing it with apache bench

ab -c 1 -n 2 -k http://localhost:3005/test.html

leads to the Problem that the second request is never being answered.
If issuing manual several test with

ab -c 1 -n 1 -k http://localhost:3005/test.html

every thing is ok.
Using a memory store session by commenting out the "store" property works also OK even with:

ab -c 10 -n 10000 -k  http://localhost:3005/test.html

I came to this striped down example from a much bigger one, where I have the problem that "sometimes" request do not get answered and time out...

Any ideas?
Thanks
Ognian

@Ognian
Copy link
Author

Ognian commented Oct 15, 2014

Hmm, could be that the problem is even deeper in express-session, since penetrating with:

 ab -c 1 -n 100 -k http://localhost:3005/test.html

when "store" is memory

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// HERE comes the problem:
var session = require('express-session');
var MongoHttpSessionStore = require('connect-mongostore')(session);

var cookieParser = require('cookie-parser');
app.use(cookieParser());

app.use(session({
        secret: "x",
        //store: new MongoHttpSessionStore(
        //    {
        //        collection: "_sTEST_delete",
        //        db: "test"
        //    }
        //),
        cookie: {
            maxAge: 60000 * 30
        }, // in minute(s) from milliseconds-> *60000
        // the following are both default true
        resave: true,
        saveUninitialized: true
    }
));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

leads to 16 completed requests...

@diversario
Copy link
Owner

So it looks like express folks are looking into this. Do you want to keep this issue open?

@Ognian
Copy link
Author

Ognian commented Oct 22, 2014

Hello,
sorry for the late answer.
I think we should let it open. The express guys where unable to reproduce and it could be that I have somehow oversimplified the test case and that I've reached now some limit with ab testing. In my actual app I was able to reproduce the problem just by using a browser and not a load test..
I need to finish up now some other things and thereafter I will go again thru the whole process and report here...
Thanks
Ognian

@Ognian
Copy link
Author

Ognian commented Nov 27, 2014

closing this for the reasons explained in expressjs/session#91
Thanks
Ognian

@Ognian Ognian closed this as completed Nov 27, 2014
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

2 participants