Firebug显示一些Socket.IO请求在红色其他黑色

时间:2016-07-21 04:03:20

标签: socket.io firebug

相同的URL有时显示为红色,而其他时间显示为黑色。我看不出这两个请求之间的区别。有谁知道为什么?

我使用的版本是:

  • Firebug 2.0.17b1
  • Firefox 43.0.1
  • Socket.IO 1.4.5
  • Node.js 6.3.0

服务器端代码非常简单:

var http = require('http')
var _server = http.createServer();
var io = require('socket.io').listen(_server);

// QUESTION: I still get CORS errors although I have these allowed origins:
io.set('origins', "ws://localhost:* ws://127.0.0.1:* http://localhost:* http://127.0.0.1:*");

_server.listen(63143);

io.sockets.on('connection', function (socket) {
    console.log("EventServer: connection");

    socket.on('disconnect', function () {
        console.log("EventServer: disconnect");
    });
});

var url = require('url');
_server.on('request', function (req, res) {
    console.log('EventServer: client request: ' + req.url);

    res.writeHead(200, {"Content-Type": "text/html"});
    //res.write('OK');  <========= QUESTION: this throws 'write after end' exception. Why?
    res.end();
});

0 个答案:

没有答案