我的SSE出现问题,如果在localhost上运行可以正常运行,但是尝试将其部署在self.scrollPinch.addSubview(newImageView)
self.view.addSubview(self.scrollPinch)
上时,则无法正常工作。数据到达客户端需要很长时间,根据chrome上的网络日志,通常需要2.1分钟才能到达。
我有这条路线
self.view.addSubview(self.scrollPinch)
self.scrollPinch.addSubview(newImageView)
这是给客户的
openode.io
但是,如果我最后做router.get('/referrals/:id', auth.verifyToken, (req, res) => {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive'
});
res.write('\n');
account.listAccountTPBS(req.params.id, tpbs => {
console.log('sent: ' + JSON.stringify(tpbs))
res.write('data:' + JSON.stringify(tpbs) + '\n\n');
res.flushHeaders();
});
});
,浏览器会立即收到日期,但这不是故意的。