I am using NodeJS server and an Android client, but at the moment of creating the Socket.IO connection, I keep receiving XHR error. Find here the troubleshooting I have done.
Client side:
The permissions are already configured.
<uses-permission android:name="android.permission.INTERNET" />
<application
android:usesCleartextTraffic="true"
In a separate class I have the following:
try {
socketio = IO.socket("http://192.168.1.76:3001/");
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
In the server side I have the following:
const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
io.on('connection', (socket) => {
console.log('a user connected');
});
app.get('/', (req, res) => {
res.sendFile(__dirname + '/index.html');
});
server.listen(3001,"0.0.0.0", () => {
console.log('listening on *:3001');
});
The IP that I am using in the socket is from here:
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . : lan
Temporary IPv6 Address. . . . . . : 2001:818:e2d4:6600:383e:7231:7f32:4c0
IPv6 Address. . . . . . . . . . . : 2001:818:e2d4:6600:d556:2d6c:bbd4:ecf1
Link-local IPv6 Address . . . . . : fe80::d556:2d6c:bbd4:ecf1%11
IPv4 Address. . . . . . . . . . . : 192.168.1.76
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
And the error I keep receiving is this one:
V/Socket Test: com.github.nkzawa.engineio.client.EngineIOException: xhr poll error
I would appreciate any help.