本文介绍了使用ipv6的node.js + express + socket.io?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码如下:
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) {...});
我将gzippo用于gzip,将express用于http服务器,将socket.io用于websocket功能.
I use gzippo for gzip, express for http server, socket.io for websocket function.
此后的代码现在可以正确处理来自ipv4地址的请求.
The code beyond now work properly with requests from a ipv4 address.
那么如何监听来自我的ipv6地址的请求?
So how to listen a request from my ipv6 address?
推荐答案
由于无法解析ipv6网址,因此socket.io似乎无法连接,请参见 https://github.com/LearnBoost/socket.io-client/issues/260
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
这篇关于使用ipv6的node.js + express + socket.io?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!