【问题标题】:(IONIC 2) Error : socket.io integrate express, GET http://localhost:3000/socket.io/?EIO=3&transport=polling&t=LvraMVg 404 (Not Found) (WEBRTC)(IONIC 2)错误:socket.io 集成快递,GET http://localhost:3000/socket.io/?EIO=3&transport=polling&t=LvraMVg 404(未找到)(WEBRTC)
【发布时间】:2017-09-12 10:24:11
【问题描述】:

我遇到了一个错误,我正在尝试从 ionic2 访问我的节点服务器,

信息:

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

问题: 1.当我在android设备上运行它时,使用命令ionic cordova run android,一切错误,当我检查检查->控制台时,

这就是控制台所说的:

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

我将附上下面的代码。 server.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);

【问题讨论】:

    标签: node.js sockets socket.io ionic2 webrtc


    【解决方案1】:

    已经解决了,

    我添加了白名单插件,

    cordova插件添加cordova-plugin-whitelist --save

    希望这个案例对未来的其他人有所帮助..

    【讨论】:

      猜你喜欢
      • 2017-09-04
      • 2020-11-24
      • 1970-01-01
      • 1970-01-01
      • 2017-02-25
      • 1970-01-01
      • 1970-01-01
      • 2021-07-09
      • 2016-03-08
      相关资源
      最近更新 更多