I'm build an WP app using HTML5/js/CSS, and today i got a problem. I create a NodeJs server using socket.io fot chat. 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/');
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
.
In package.appxmanifest, i checked Internet ( Client & Server ) Capabilities.
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)
). 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.