Skip to content
Advertisement

socketio.emit doesn’t work netty socketio

I’m working with socketio and netty with java and I’m new to both of them.

my client side code looks like this.

JavaScript

The event handler is as shown below.

JavaScript

The server starter code is shown below.

JavaScript

I’m getting a connection registration on the OnConnect annoted method, but the method seems to run two times cause I get the log twice while the socket connects. I don’t know why it happens.

But even worse is the emit method doesn’t work that is written in client side javascript. There is no error. The log below the emit is executed. But the OnEvent annoted method in the java EventHandler doesn’t seem to detect it.

Can someone help me understand this?

Advertisement

Answer

Apparently it seems the problem is with the libraries. There is some compatibility issue with newer versions of socketio client library with netty dependencies for java and it is causing the weird problems.

My dependency for netty socketio is shown below which obviously is the latest as of answering this question.

JavaScript

And for the client library to work smoothly I had to downgrade the library from 3.X.X to 2.X.X .

In my case from

JavaScript

to

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement