加入收藏 | 设为首页 | 会员中心 | 我要投稿 阜阳站长网 (https://www.0558zz.com/)- 科技、建站、内容创作、云计算、网络安全!
当前位置: 首页 > 运营中心 > Nginx > 正文

Socket.io无法连接nginx node.js php app

发布时间:2020-07-03 13:26:45 所属栏目:Nginx 来源:互联网
导读:我试图用PHP app和node.js一起运行nginx(这部分工作正常).另外我想将socket.io添加到此设置中,但不幸的是我无法在客户端和服务器之间建立连接(看起来像连接超时?).server.jsvar app = require(http), redis = require(redis), io = require(so

我试图用PHP app和node.js一起运行nginx(这部分工作正常).另外我想将socket.io添加到此设置中,但不幸的是我无法在客户端和服务器之间建立连接(看起来像连接超时?).

server.js

var app = require("http"),redis = require("redis"),io = require('socket.io')(app);


io.sockets.on( 'connection',function( client ) {
    console.log( "New client !" );

    io.sockets.emit('msg',{ msg: 'Foo bar' } );
});

app.createServer().listen(3000);
console.log("Server running at 127.0.0.1:3000");

client.js