Friday 19 May 2017

Socket.io "headers already sent" after update

after updating socket.io from version 1.3.5 to 2.0.1 Im getting error when connecting to server: "headers already sent", but not always, sometimes it works.

I updated also node(4.5.0=>6.10.3) and express(4.14.0=>4.15.3) but i feel it's socket.io problem.

This is my code, it's working on 1.3.5 without problems:

var app = require("express")();
var https = require('https');

var server = https.createServer({ 
                key: fs.readFileSync('key.key'),
                cert: fs.readFileSync('cert.crt'),
                ca: fs.readFileSync('Chain-SHA2.crt'),
                requestCert: false,
                rejectUnauthorized: false
             },app);
server.listen(8081);

var io = require('socket.io')(server);



app.post("/xxx", function(request, response) {
    //some code
});

app.listen(8080);



io.on('connection', function(socket){
    //some code
});



via Jack Shperack

No comments:

Post a Comment