node.js+express+socket.io with ipv6?

久未见 提交于 2019-12-11 05:33:43

问题


I have my code like below:

var gzippo = require('gzippo');

var app = require('express').createServer()
  , io = require('socket.io').listen(app);

io.enable('browser client gzip');
io.set('transports', [
    'websocket'
]);

app.use(gzippo.staticGzip(__dirname + '/'));

app.listen(8001);

app.get('/', function (req, res) {
  res.sendfile(__dirname + '/main2.html');
});

io.sockets.on('connection', function (socket) {...});

I use gzippo for gzip, express for http server, socket.io for websocket function.

The code beyond now work properly with requests from a ipv4 address.

So how to listen a request from my ipv6 address?


回答1:


It appears that socket.io fails to connect as it is unable to parse ipv6 url, cf https://github.com/LearnBoost/socket.io-client/issues/260



来源:https://stackoverflow.com/questions/8550656/node-jsexpresssocket-io-with-ipv6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!