0
與其他不同,對於我來說,EventSource在Chrome和Firefox中都被觸發並正常工作。但是在Firefox中,當我在瀏覽器中收到消息時,我會收到一條錯誤消息。在Chrome中不會發生。Firefox中異常的EventSource錯誤
客戶端代碼:
var source = new EventSource('***');
source.addEventListener('message', function(event) {
...
}, false);
source.addEventListener('ping', function(e) {
...
}, false);
source.addEventListener('error', function(e) {
... // now this part gets executed in firefox, whenever i recieve a msg
}, false);
服務器的NodeJS代碼:
***.on('fin',function(message){
delete ***;
res.header('Content-Type', 'text/event-stream');
res.write('data: '+JSON.stringify(message)+'\n\n');
res.end();
});
***.on('busError',function(){
delete ***;
res.send(500);
});
嗯,*你得到了什麼*錯誤信息? – Bergi 2014-08-29 12:07:08
您可以添加您正在使用的Node.JS服務器模塊嗎?我使用'http'並沒有遇到這個問題,但是我可能沒有足夠強調它? 'message'字符串有多大? – 2014-08-30 10:34:21
@bergi,我收到的錯誤信息是空的,信息很小,100-200個字符,好奇的是,錯誤什麼也沒有做,只是出現。但將「傳輸編碼」更改爲「身份」固定了它。 – mido 2014-08-31 23:33:47