I'm testing out your socket.io solution...
I've got 1 Test user, using chrome browser (latest version) + socket.io (latest JS version)
Our Resin4 server: Using your "socket.io-client" solution, this server sends out notifications to our test user via the socket server
wsclient.js - connection setup
$(function () {
// make connection
let socket = io.connect();
console.log("Websocket connected");
...
I've tested this setup with node.js+socket-io server.js (a more complete script than the code below) and it works perfectly.
Now, as a test, I decided to disable node.js and try your socket.io-server solution by following your documentation (as best I could), I've modified it slightly, but I get the same quirks whether I follow your instructions explicitly or not.
I start my Resin4 server (same server mentioned above, but including the following servlet)
It runs ok for a few seconds handling the socket.io-client(java) connection ok, but then it then has major issues (described further below).
Note:
I also tried
let socket = io.connect('ws://localhost:8080/socket.io/?user=test');
with same results
package servlet;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import io.socket.emitter.Emitter;
import io.socket.engineio.server.EngineIoServer;
import io.socket.socketio.server.SocketIoNamespace;
import io.socket.socketio.server.SocketIoServer;
import io.socket.socketio.server.SocketIoSocket;
@WebServlet("/socket.io/*")
public class SocketIoServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
private final EngineIoServer mEngineIoServer = new EngineIoServer();
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("[WEBSOCKET] SOCKET.IO: doGet");
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("[WEBSOCKET] SOCKET.IO: doPost");
}
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
mEngineIoServer.handleRequest(request, response);
SocketIoServer mSocketIoServer = new SocketIoServer(mEngineIoServer); // << this seems to result in less repeated iterations
SocketIoNamespace namespace = mSocketIoServer.namespace("/");
namespace.on("connection", new Emitter.Listener() {
@Override
public void call(Object... args) {
SocketIoSocket socket = (SocketIoSocket) args[0];
System.out.println("[SOCKET.IO] Connection. Args=" + args.length+" Socket id=" + socket.getId());
socket.on("message", new Emitter.Listener() {
@Override
public void call(Object... args) {
try {
System.out.println("[SOCKET.IO] Message. Args=" + args.length);
System.out.println(args[0]);
} catch (Exception e) {
System.out.println("Error");
}
}
});
socket.on("notify", new Emitter.Listener() {
@Override
public void call(Object... args) {
try {
System.out.println("[SOCKET.IO] Message. Args=" + args.length);
System.out.println(args[0]);
} catch (Exception e) {
System.out.println("Error");
}
}
});
socket.on("ping", new Emitter.Listener() {
@Override
public void call(Object... args) {
System.out.println("[SOCKET.IO] Ping");
}
});
socket.on("pong", new Emitter.Listener() {
@Override
public void call(Object... args) {
System.out.println("[SOCKET.IO] Pong");
}
});
socket.on("error", new Emitter.Listener() {
@Override
public void call(Object... args) {
System.out.println("[SOCKET.IO] Error");
}
});
}
});
}
public void init() throws ServletException {
System.out.println("[WEBSOCKET] SOCKET.IO: Init");
}
public void destroy() {
System.out.println("[WEBSOCKET] SOCKET.IO: DESTROYED");
}
}
The log file reports...
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
[SOCKET.IO] Connection. Args=1 Socket id=N9k8mvJ
(repeats forever(?))
WarningService: Shutdown: TcpSocketLink OutOfMemory
[20-06-01 13:11:54.045] {EventThread} Task threw exception
java.lang.OutOfMemoryError: GC overhead limit exceeded
at io.socket.engineio.client.Transport.onError(Transport.java:63)
at io.socket.engineio.client.transports.PollingXHR.access$100(PollingXHR.java:26)
at io.socket.engineio.client.transports.PollingXHR$6$1.run(PollingXHR.java:140)
at io.socket.thread.EventThread$2.run(EventThread.java:80)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[20-06-01 13:11:54.045] {resin-port-8080-38} WarningService: Shutdown: TcpSocketLink OutOfMemory
Exception in thread "EventThread" java.lang.OutOfMemoryError: GC overhead limit exceeded
at io.socket.engineio.client.Transport.onError(Transport.java:63)
at io.socket.engineio.client.transports.PollingXHR.access$100(PollingXHR.java:26)
at io.socket.engineio.client.transports.PollingXHR$6$1.run(PollingXHR.java:140)
at io.socket.thread.EventThread$2.run(EventThread.java:80)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
It looks like the listener is refusing the connection
Is there something I'm missing??
Is there something your documentation is missing?
Do you have a demonstration example of -say- a simple echo server that you could share?
Some help would be appreciated