代码之家  ›  专栏  ›  技术社区  ›  adityajhordan

(2)错误:套接字。io integrate express,获取http://localhost:3000/socket.io/?EIO=3&transport=polling&t=LvraMVg404(未找到)(WEBRTC)

  •  0
  • adityajhordan  · 技术社区  · 9 年前

    1.我正在自己的笔记本电脑上构建节点服务器 2.当我运行ionic serve时,所有操作都正常。。聊天没问题,一切都好。

    问题: 1.当我在android设备上运行它时,使用命令 ionic cordova run android ,所有错误,当我检查检查时->安慰

    获取 http://myIpIsHere:3000/socket.io/?EIO=3&transport=polling&t=LvraMVg 404(未找到)

    我将附上下面的代码。 服务器js公司

    var socket = require('socket.io'),
    http = require('http'),
    server = http.createServer(),
    socket = socket.listen(server);
    
    socket.on('connection', function(connection) {
        console.log('User Connected');
    
        connection.on('sendid', function(id){
            socket.emit('id', id);
            console.log('triger isi apa : ', id);
        });
    
        connection.on('message2', function(msg){
            console.log('triger isi msg apa :', msg);
            socket.emit('message2', msg);
        });
    
        connection.on('message', function(msg){
            console.log('triger isi msg apa :', msg);
            socket.emit('message', msg);
        });
    });
    
    server.listen(3000, function(){
        console.log('Server started');
    });
    

    这是我的ionic2,尝试访问服务器

    this.statisticServer="http://myIpIsHere:3000/";
    console.log('server :', this.statisticServer );
    this.socket = io(this.statisticServer);
    
    1 回复  |  直到 9 年前
        1
  •  0
  •   adityajhordan    9 年前

    已经解决,

    我添加了白名单插件,

    希望这个案例对其他人有帮助。。