Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 套接字io.connect即使在端口启用后也不工作_Node.js_Socket.io - Fatal编程技术网

Node.js 套接字io.connect即使在端口启用后也不工作

Node.js 套接字io.connect即使在端口启用后也不工作,node.js,socket.io,Node.js,Socket.io,我连接套接字的代码是: var socket = io.connect('http://localhost:3003', { query: $.param({des: user_info, pic: user_pic}) ] }) 它在本地系统上工作,但在aws服务器上不工作,因为我启用了端口3003 服务器代码-- 这个=>http://localhost:3003在AWS中工作?不,不是在AWS中工作,我在AWS中尝试过1)“ws://my A

我连接套接字的代码是:

  var socket = io.connect('http://localhost:3003', {
                    query: $.param({des: user_info, pic: user_pic})
]  })
它在本地系统上工作,但在aws服务器上不工作,因为我启用了端口3003

服务器代码--


这个=>
http://localhost:3003
在AWS中工作?不,不是在AWS中工作,我在AWS中尝试过1)“ws://my AWS ip:3003”2“3)”,但在点击“npm start”后,它会一直到app.get('/',function(req,res){res.sendFile(u dirname+'/index.html');});您是否尝试过“”?是的,尝试过,但工作到,app.get('/',function(req,res){res.sendFile(uu dirname+'/index.html');});但无法在io.on('connection',function(socket){}之间进行:
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
//var find = require('array-find');

var port = process.env.PORT || 3003;
var all = [];

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


io.on('connection', function (socket) {
  // not comming here 
});