我想在我的公共IP上加载我的套接字服务器,因为我现在只能在局域网localhost:8080
或127.0.0.1:8080
加载它。我想连接自己的IP 77.90.100.55:8080
。
我不知道为什么,但我无法使用
io.connect('http://77.90.100.55:8888');
要连接,只有这个有效:
io.connect('http://localhost:8888');
当我尝试与77.90.100.55
连接时,我在客户端收到此错误:
polling-xhr.js:264 GET http://77.90.100.55:3000/socket.io/?EIO=3&transport=polling&t=LpBv_sK net :: ERR_CONNECTION_TIMED_OUT
var http = require("http").createServer(), io = require("socket.io").listen(http);
var port = process.env.PORT || 3000;
http.listen(port);
//================================ Connection stuff ================================//
io.sockets.on("connection", function(socket)
{
socket.on('player connected', function(data)
{
});
});
console.log('Server listening on port %s', http.address().port);
我可以使用所有端口和公共IP,我可以通过命令行访问我的IP:
Pinging 77.90.100.55 with 32 bytes of data:
Reply from 77.90.100.55: bytes=32 time<1ms TTL=64
Reply from 77.90.100.55: bytes=32 time<1ms TTL=64
Reply from 77.90.100.55: bytes=32 time<1ms TTL=64
Reply from 77.90.100.55: bytes=32 time<1ms TTL=64
Ping statistics for 77.90.100.55:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
我使用start.bat
运行节点服务器:
node C:\xamppp\htdocs\pure2d\server\server.js 2>error_log.log
答案 0 :(得分:0)
<强>固定强> 我使用网站http://whatismyipaddress.com/获取我的IP,但我忘了我有wifi路由器改变我的IP,我只能从电脑网络和共享面板检查ip,因为网站无法显示它