It works using browser, but when I build apk and install it to the phone.. it doesn't connect to server.
Server code:
var http = require('http');
var port = process.env.port || 80;
var server = http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World 2.14');
}).listen(port);
var io = require('socket.io').listen(server);
io.sockets.on('connection', function(socket){
console.log('user connected'); // Server receive this log if it's opened with browser, but NO response using APK.
});
Client is connecting using this code:
var socket = io.connect('https://irvelbandom01.azurewebsites.net');
I changed confix.xml so it would allow to connect to azure domain:
<access origin="https://irvelbandom01.azurewebsites.net*" />
what should I do?
I Found the problem:
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
Still dont know why but after I changed the path it works!
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>