[英]GET http://localhost/socket.io/?EIO=3&transport=polling&t=LjIvLGU 404 (Not Found)
[英](IONIC 2) Error : socket.io integrate express, GET http://localhost:3000/socket.io/?EIO=3&transport=polling&t=LvraMVg 404 (Not Found) (WEBRTC)
我遇到错误,我正在尝试从ionic2访问我的节点服务器,
信息:
1.我正在我自己的笔记本电脑上构建节点服务器。2.当我运行离子服务时,所有工作正常..聊天没问题,都很好。
问题:1.当我在android设备上运行它时,使用ionic cordova run 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);
已经解决了
我添加了白名单插件,
cordova插件添加cordova-plugin-whitelist --save
希望此案对以后有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.