I am trying to connect my socket client in spring boot application to my node js socket server. The node js client code is as below.
socket = io('localhost:3000', {
path: 'https://localhost:3000/socket.io',
auth: {
token: "abcd",
},
});
That works fine, the equivalent code in spring boot application is as follow:
IO.Options options = IO.Options.builder()
.setAuth(singletonMap("token","abcd"))
.build();
Socket socket = IO.socket(URI.create("https://localhost:3000"), options);
socket.connect();
But I get this error client io.socket.engineio.client.EngineIOException: xhr poll error
And If I add transport options.transports = new String[] {WebSocket.NAME }
, I get this error io.socket.engineio.client.EngineIOException: websocket error
. I have aslo checked version's compatibility. https://socketio.github.io/socket.io-client-java/installation.html. Socket server 4.x is compatible with client's version 2.1.0.
I'm using socket.io-client dependency as follows.
<dependency>
<groupId>io.socket</groupId>
<artifactId>socket.io-client</artifactId>
<version>2.1.0</version>
</dependency>
Any clues, how to fix this as I have provided the auth parameter as well and everything seems fine.