Best java server implementation for socket.io
Asked Answered
C

3

51

I wanted to use socket.io to push data from server to browser but the project is java tomcat one, and there are many implementation in Github for the server implementation of socket.io. Most of them say they are deprecated or better ones are available.Can anyone suggest me a good implementation.

And I see lot of demo and sample code about broadcasting with socket.io. My requirement is to push different messages to different clients. Could someone point me to some good demo or tutorial dealing with such stuff?

Thanks

Crispy answered 22/3, 2013 at 11:1 Comment(2)
As far as just looking for a java implementation of socket-io there are many,but their support for many containers is not good.SO the choice i took was to go with atmosphere,It gives you the option to use socket io as the lirary or theirs and some others and it does support most of the containers out there.It seems to be an actively developed project and i would recommend it to anyone in the same situation of doing comet in javaCrispy
possible duplicate of how to implement Socket.io on Tomcat 7Explanation
C
55

As author, I suggest to try my SocketIO server implementation on Java:

https://github.com/mrniko/netty-socketio

Stable and production ready lib.

Coseismal answered 23/5, 2013 at 10:45 Comment(8)
Netty-socketio creates its own server or I can use it inside a Tomcat application, for example?Momism
@NikitaKoksharov Hi, is there any formal documentation for netty-socketio that I could use as a reference while building my software around it?Tomi
Nikita thanks for the lib, took few minutes to get everything working for me, i wish more people know how to design stuff like you...Chunk
Have you used the Atmosphere Framework. How does it compare?Hedron
@NikitaKoksharov Can I use the netty-socketio framework EndPoint based implementation.Hollingshead
@SajibAcharya you can check out this demo github.com/mrniko/netty-socketio-demoTautologize
After a POC I am thinking to use it in our product with tomcat 8. But the GitHub repo last commit was on 29 September 2020. Is the repo still active and maintainedAsturias
@NikitaKoksharov it's really interesting implementation, but I can't found supporting v3 and v4 socket.io clients. Is it possible to add support v4?Undertake
C
6

We are using in production this one: Socket.IO-Java. We have customize it by our requirements. But in the main case it works good enough.

My colleague shared customized version in github. We are using Jetty 8, there are can be some problem with another servlet containers. Also, we consider using WebSocket only implementation, when XP will not supported by Microsoft.

Cinchona answered 27/3, 2013 at 19:33 Comment(3)
Hey thanks for the answer i did check many of these java backends.But most of them were specific to some container like the one you pointed out was for jetty.SO i took the choice to go with atmosphereCrispy
Link is dead. Could you share your customized version somewhere? (github maybe) The project's documentation says it's abandoned and your changes might be what it was missing :)Shelf
@Shelf I have added link to repoCinchona
H
3

You can try this one: https://github.com/codeminders/socket.io-server-java

This implementation is loosely based on old Socket.IO-Java library mentioned in other answers.

It supports Socket.IO 1.0+ clients. The websocket transport is implemented with Jetty 9 but there is no dependency on Jetty for core part of the library. It should not be very difficult to implement websocket transport with Tomcat if needed.

I tried to keep the API similar to Node.JS Socket.IO server API. So, to send a message to specific socket all you need is to call socket.emit()

Here is a small code fragment to be called in your SocketIO servlet:

on(new ConnectionListener() {
        public void onConnect(Socket socket)
        {
            try
            {
                socket.emit("welcome", "Welcome to Socket.IO Chat!");
            }
            catch (SocketIOException e)
            {
                socket.disconnect(true);
            }
       }
}); 
Hinton answered 26/1, 2016 at 23:37 Comment(1)
is it compatible with ios and android socket io client ?Harken

© 2022 - 2024 — McMap. All rights reserved.