[英]Winjs app cant connect nodejs socket.io server
I'm build an WP app using HTML5/js/CSS, and today i got a problem. 我正在使用HTML5 / js / CSS构建WP应用程序,但今天遇到了问题。 I create a NodeJs server using socket.io fot chat.
我使用socket.io聊天创建了一个NodeJs服务器。 My server code:
我的服务器代码:
var express = require('express')
, routes = require('./routes')
, http = require('http');
var app = express();
var mongodb = require('mongodb');
var url = 'mongodb://localhost:27017/chat';
var MongoClient = mongodb.MongoClient;
app.configure(function(){
app.set('port', process.env.PORT || 3456);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/', routes.index);
var server = http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
var io = require('socket.io').listen(server)
, guestNumber = 1
, nickNames = {}
, numuser = 0;
io.set('log level', 1);
io.on('connection', function (socket) {
...
});
In my app, i use: var socket = io.connect('myipserver:3456/');
在我的应用程序中,我使用:
var socket = io.connect('myipserver:3456/');
IT NOT CONNECT to my server, but when i use browser to connect my ip server, it normal, and in my app, it got error: XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd
. 它未连接到我的服务器,但是当我使用浏览器连接我的IP服务器时,它是正常的,并且在我的应用程序中出现错误:
XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd
。
In package.appxmanifest, i checked Internet ( Client & Server ) Capabilities. 在package.appxmanifest中,我检查了Internet(客户端和服务器)功能。
So, do i miss something in my app ? 那么,我想念我的应用程序中的某些东西吗? Plz help.
请帮助。
After some Googling I saw this question that has the same error code as your app. 经过一番谷歌搜索后,我看到了与您的应用具有相同错误代码的问题 。 Seems to me that this error code says that the app does not see the server.
在我看来,此错误代码表明该应用程序看不到服务器。 So I don't think it's a socket-related error.
因此,我认为这不是与套接字相关的错误。
Try making a simple AJAX request to your server (with jQuery: $.get(myipserver:3456/some-static-file)
). 尝试向您的服务器发出一个简单的AJAX请求(使用jQuery:
$.get(myipserver:3456/some-static-file)
)。 If it works, then it's something with the socket communications, otherwise the app does not see the server at all. 如果能够正常工作,则说明套接字通信正常,否则该应用程序根本看不到服务器。 Good point to start from, I guess.
我想这是一个很好的起点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.