javascript - NodeJs app with Express,cause“request is not finished yet”?
黄舟
黄舟 2017-04-10 16:17:44
[JavaScript讨论组]

As the title said, i use express-session and redis deal with session. code like this:

app.use(session({
    store: new RedisStore({
        "host": "115.28.87.181",
        "port": "6379",
        "ttl": 60 * 60 * 20,
        "pass": "",
        "db": 0,
        "prefix": "session"
    }),
    name: "sessionid",
    secret: '',
    resave: true,
    saveUninitialized: true,
    cookie: {
        path: '/',
        httpOnly: false,
        secure: false,
        maxAge: 60 * 60 * 20
    },
    rolling: true,
    unset: "destroy"
}));

It can store session and works well.

When i request a link like http://127.0.0.1/sign/availd_id?id=tosone make sure which id is available. Problems are coming in Chrome except firefox and safari.

My NodeJs server will response to chrome {code: 200, and wait for a long long time, the browser state is request is not finished yet, and JS is not run.

After a long long time about 2 minutes, Chrome will get the full information {code:200}. it looks like the browser wait for the }.

But the Server Log said it had responsed the whole information to browser long before. the log is this:GET /sign/availd_id?id=tosone 200 73.555 ms, it comes when i refresh the browser.

there is nothing with http keep-alive in my code.

Remove the code above or with firefox, problems will never been like that.

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(4)
PHP中文网

我也遇到这个问题了,
触发条件
1、在用session
2、同时用res.json({code:1, msg:'success'});

就也会出现这个问题,一直要等待2分钟。很诡异。求帮助

高洛峰

关于这个问题我觉得可能是因为用了远程的redis的原因,我尝试着换成了本地的redis就不会出现无限加载的情况了。

PHP中文网

遇到同样的问题,但是没有发现必然规律。唯一可以确认的是:火狐一直好好的,就chrome有问题,而且会偶尔没有问题。

大家讲道理
  1. 在用express-session

  2. windows 10, chrome 51

  3. 系统升完级就没问题了

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号