Socket.IO server implemented on Java. Realtime java framework

Overview

Netty-socketio Overview

This project is an open-source Java implementation of Socket.IO server. Based on Netty server framework.

Checkout Demo project

Licensed under the Apache License 2.0.

Features

  • Supports 0.7...0.9.16 (netty-socketio 1.6.6) and 1.0+ (netty-socketio latest version) version of Socket.IO-client
  • Supports xhr-polling transport
  • Supports websocket transport
  • Supports namespaces and rooms
  • Supports ack (acknowledgment of received data)
  • Supports SSL
  • Supports client store (Memory, Redisson, Hazelcast)
  • Supports distributed broadcast across netty-socketio nodes (Redisson, Hazelcast)
  • Supports OSGi
  • Supports Spring
  • Lock-free and thread-safe implementation
  • Declarative handler configuration via annotations

Performance

Customer feedback in 2012:
CentOS, 1 CPU, 4GB RAM runned on VM: CPU 10%, Memory 15%
6000 xhr-long polling sessions or 15000 websockets sessions
4000 messages per second

Customer feedback in 2014:
"To stress test the solution we run 30 000 simultaneous websocket clients and managed to peak at total of about 140 000 messages per second with less than 1 second average delay." (c) Viktor Endersz - Kambi Sports Solutions

Projects using netty-socketio

AVOS Cloud: avoscloud.com
Bingo Crack: bingocrack.com
Kambi Sports Solutions: kambi.com
ARSnova: arsnova.eu
Zipwhip: zipwhip.com

Recent Releases

Please Note: trunk is current development branch.

17-Jan-2020 - version 1.7.18 released

Feature - support for event interceptors which catch all events (thanks to yosiat)
Fixed - namespace event broadcasting (thanks to Volodymyr Masliy)

11-Jan-2019 - version 1.7.17 released

Feature - randomSession setting added to Config object (thanks to yuanxiangz)
Fixed - NPE in WebSocketTransport
Fixed - NPE & memory leak (thanks to zhaolianwang)
Fixed - namespace parsing (thanks to Redliver)
Fixed - Redisson 3.9+ compatibility

06-Jul-2018 - version 1.7.16 released

Fixed - non thread-safe ACK handling (thanks to dawnbreaks)
Fixed - inactive long-polling channels cause memory leak (thanks to dawnbreaks)
Fixed - websocket CloseFrame processing (thanks to hangsu.cho)
Fixed - WebSocketTransport NPE

15-May-2018 - version 1.7.15 released

Fixed - Session ID is not unique anymore
Fixed - fixed underlying connection not closing on ping timeout
Fixed - the "fin_close" problem

26-Feb-2018 - version 1.7.14 released

Feature - added local socket address for the connection (thanks to @SergeyGrigorev)
Feature - addPingListener method added (thanks to @lovebing)
Feature - add ThreadFactory for HashedWheelTimer (thanks to @hand515)
Fixed - changed SO_LINGER to be handled as child channel (not server channel) option (thanks to @robymus)
Fixed - ByteBuf leak if binary attachments are used
Fixed - restore session from Cookie (thanks to @wuxudong)
Fixed - NumberFormatException when b64 is bool value (thanks to @vonway)
Fixed - data encoding for polling transport

20-Sep-2017 - version 1.7.13 released

Feature - Added option to change the SSL KeyFactoryAlgorithm using Configuration (thanks to @robymus)
Improvement - Binary ack handling improvements (thanks to Sergey Bushik)
Fixed - Failed to mark a promise as success because it has succeeded already (thanks to @robymus)

27-Aug-2016 - version 1.7.12 released

Feature - SocketIOServer.removeAllListeners method added
Feature - BroadcastOperations.sendEvent method with excludedClient param added
Improvement - Redisson updated to 2.4.0
Fixed - memory leak in Namespace object (thanks to @CrazyIvan007)

13-Jul-2016 - version 1.7.11 released

Fixed - Throw error if transport not supported
Fixed - Client disconnecting when using Polling - IndexOutOfBoundsException

4-Mar-2016 - version 1.7.10 released

Fixed - netty updated to 4.1.0.CR3 version
Fixed - binary packet parsing (thanks to Winston Li)

6-Feb-2016 - version 1.7.9 released

Feature - Compression support
Fixed - DotNET client request handling
Fixed - Packet length format parsing
Fixed - skipping 'd=' in packet
Fixed - Polling clients sporadically get prematurely disconnected (thanks to lpage30)
Fixed - connections stay open forever if server sent close packet
Fixed - compatibility with Redisson latest version

30-Nov-2015 - version 1.7.8 released

Improvement - WebSocketServerHandshaker.allowExtensions is true now
Improvement - SessionID cookie implementation (thanks to @ryandietrich)
Fixed - clientRooms leak (thanks to @andreaspalm)
Fixed - ExceptionListener not used for errors in JSON parsing
Fixed - "silent channel" attack

26-Mar-2015 - version 1.6.7 released

Improvement - useStrictOrdering param added for websocket packets strict ordering
Improvement - FAIL_ON_EMPTY_BEANS = false option setted in json decoder

18-Feb-2015 - version 1.7.7 released

Improvement - no need to add jackson lib if you use own JsonSupport impl
Fixed - SocketIO client 1.3.x support
Fixed - Charset encoding handling (thanks to alim-akbashev)

17-Jan-2015 - version 1.7.6 released

Improvement - SocketIONamespace.getName() added
Fixed - WebSocket frames aggregation
Fixed - WebSocket buffer release
Fixed - Unexpected end-of-input in VALUE_STRING error
Fixed - Access-Control-Allow-Credentials is TRUE for requests with origin header

05-Dec-2014 - version 1.7.5 released

Feature - Configuration.sslProtocol param added
Fixed - BinaryEvent ack handling
Fixed - BinaryEvent non b64 encoding/decoding
Fixed - buffer leak during packet encoding

15-Nov-2014 - version 1.7.4 released

Fixed - packet encoding
Fixed - BinaryEvent encoding/decoding
Fixed - unchallenged connections handling

29-Sep-2014 - version 1.6.6 released

Feature - origin setting added
Feature - crossDomainPolicy setting added
Feature - SocketIOServer.startAsync method added

24-Sep-2014 - version 1.7.3 released

Feature - Epoll support
Improvement - BinaryEvent support
Fixed - SocketIOClient disconnect handling
Fixed - broadcast callback
Fixed - NPE then no transport defined during auth
Fixed - ping timeout for polling transport
Fixed - buffer leak in PacketEncoder

22-Aug-2014 - version 1.7.2 released

Fixed - wrong outgoing message encoding using websocket transport
Fixed - NPE in websocket transport
Fixed - multiple packet decoding in polling transport
Fixed - buffer leak

07-Jul-2014 - version 1.7.1 released

Feature - ability to set custom Access-Control-Allow-Origin via Configuration.origin
Fixed - connection via CLI socket.io-client

28-Jun-2014 - version 1.7.0 released

Feature - Socket.IO 1.0 protocol support. Thanks to the new protocol decoding/encoding has speedup
Dropped - SocketIOClient.sendMessage, SocketIOClient.sendJsonObject methods and corresponding listeners
Dropped - Flashsocket transport support
Dropped - protocol version 0.7 ... 0.9.16

13-May-2014 - version 1.6.5 released

Improvement - single packet encoding optimized, used mostly in WebSocket transport. Encoding time reduced up to 40% (thanks to Viktor Endersz)
Improvement - rooms handling optimized
Improvement - ExceptionListener.exceptionCaught method added
Breaking api change - Configuration.autoAck replaced with ackMode
Feature - trustStore setting added
Feature - maxFramePayloadLength setting added
Feature - getAllClients and getClient methods added to SocketIONamespace
Fixed - SocketIOServer.getAllClients returns wrong clients amount

25-Mar-2014 - version 1.6.4 released

Fixed - message release problem
Fixed - problem with exception listener configuration redefinition
Breaking api change - DataListener.onData now throws Exception
Improvement - data parameter added to exception listener
Improvement - ability to setup socket configuration
Improvement - Configuration.autoAck parameter added

06-Mar-2014 - version 1.6.3 released

Fixed - AckCallback handling during client disconnect
Fixed - unauthorized handshake HTTP code changed to 401
Breaking api change - Configuration.heartbeatThreadPoolSize setting removed
Feature - annotated Spring beans support via SpringAnnotationScanner
Feature - common exception listener
Improvement - ScheduledExecutorService replaced with HashedWheelTimer

08-Feb-2014 - version 1.6.2 released

Fixed - wrong namespace client disconnect handling
Fixed - exception in onConnect/onDisconnect/isAuthorized methods leads to server hang
Breaking api change - SocketIOClient.sendEvent methods signature changed
Improvement - multi type events support via MultiTypeEventListener and OnEvent annotation
Improvement - multi type events ack support via MultiTypeAckCallback
Improvement - SocketIOClient.getHandshakeData method added
Improvement - Jedis replaced with Redisson

14-Jan-2014 - version 1.6.1 released

Fixed - JDK 1.6+ compatibility
Feature - authorization support

19-Dec-2013 - version 1.6.0 released

Fixed - XHR-pooling transport regression
Fixed - Websocket transport regression
Fixed - namespace NPE in PacketHandler
Fixed - executors shutdown during server stop
Feature - client store (Memory, Redis, Hazelcast) support
Feature - distributed broadcast across netty-socketio nodes (Redis, Hazelcast) support
Feature - OSGi support (thanks to rdevera)
Improvement - XHR-pooling optimization
Improvement - SocketIOClient.getAllRooms method added

07-Dec-2013 - version 1.5.4 released

Fixed - flash policy "request leak" after page reload (thanks to ntrp)
Fixed - websocket swf loading (thanks to ntrp)
Fixed - wrong urls causes a potential DDoS
Fixed - Event.class package visibility changed to avoid direct usage
Improvement - Simplified Jackson modules registration

24-Oct-2013 - version 1.5.2 released

Fixed - NPE during shutdown
Improvement - isEmpty method added to Namespace

13-Oct-2013 - version 1.5.1 released

Fixed - wrong ack timeout callback invocation
Fixed - bigdecimal serialization for JSON
Fixed - infinity loop during packet handling exception
Fixed - 'client not found' handling

27-Aug-2013 - version 1.5.0 released

Improvement - encoding buffers allocation optimization.
Improvement - encoding buffers now pooled in memory to reduce GC pressure (netty 4.x feature).

03-Aug-2013 - version 1.0.1 released

Fixed - error on unknown property during deserialization.
Fixed - memory leak in long polling transport.
Improvement - logging error info with inbound data.

07-Jun-2013 - version 1.0.0 released

First stable release.

Maven

Include the following to your dependency list:

<dependency>
 <groupId>com.corundumstudio.socketio</groupId>
 <artifactId>netty-socketio</artifactId>
 <version>1.7.12</version>
</dependency>

Supported by

YourKit is kindly supporting this open source project with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit .NET Profiler.

Issues
  • 1.7.3 leak memory && Unexpected end-of-input in VALUE_STRING

    1.7.3 leak memory && Unexpected end-of-input in VALUE_STRING

    Hi. I use a framework(1.7.3 version) already some time and I have accumulated a number of issues:).

    1. Memory leak when loading Blobs: ServerSIde
    public class FileDTO {
        private byte[] data;
        public FileDTO(int id, byte[] data, String error, String key, String name, String sql) {
            super();
           ...
            this.data = data;
           ...
        }
        ...
    }
    
    public class Launcher {
      public static void main(String[] args) throws InterruptedException {
    ...
      Configuration config = new Configuration();
            config.setHostname("192.168.0.34");
            config.setPort(3000);
            config.setMaxFramePayloadLength(10000000);
            config.setMaxHttpContentLength(10000000);
            final SocketIOServer server = new SocketIOServer(config);
    
    ....
     }
    ....
      server.addEventListener("fileUpload", FileDTO.class, new DataListener<FileDTO>() {
                Connection conn = new WebService();
                @Override
                public void onData(SocketIOClient client, FileDTO data, AckRequest ackRequest) {
                   //code for upload file
                }
            });
    }
    

    Client Side

    socket.emit('fileUpload', {
      data: base64Data
    ..
    })
    

    Problem: when I upload a large file( ~150+kb ), the server generates an error

    type: class com.corundumstudio.socketio.protocol.Event
    com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input in VALUE_STRING
     at [Source: [email protected]; line: 1, column: 129893]
            at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1419)
            at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:508)
            at com.fasterxml.jackson.core.base.ParserMinimalBase._reportInvalidEOF(ParserMinimalBase.java:445)
            at com.fasterxml.jackson.core.base.ParserMinimalBase._reportInvalidEOF(ParserMinimalBase.java:441)
            at com.fasterxml.jackson.core.base.ParserBase.loadMoreGuaranteed(ParserBase.java:408)
            at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishString2(UTF8StreamJsonParser.java:2184)
            at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishString(UTF8StreamJsonParser.java:2165)
            at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.getText(UTF8StreamJsonParser.java:279)
            at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeObject(JsonNodeDeserializer.java:224)
            at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeArray(JsonNodeDeserializer.java:262)
            at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:64)
            at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:14)
            at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3023)
            at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:1705)
            at com.corundumstudio.socketio.protocol.JacksonJsonSupport$EventDeserializer.deserialize(JacksonJsonSupport.java:140)
            at com.corundumstudio.socketio.protocol.JacksonJsonSupport$EventDeserializer.deserialize(JacksonJsonSupport.java:126)
            at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3051)
            at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2192)
            at com.corundumstudio.socketio.protocol.JacksonJsonSupport.readValue(JacksonJsonSupport.java:223)
            at com.corundumstudio.socketio.JsonSupportWrapper.readValue(JsonSupportWrapper.java:55)
            at com.corundumstudio.socketio.protocol.PacketDecoder.decode(PacketDecoder.java:180)
            at com.corundumstudio.socketio.protocol.PacketDecoder.decodePackets(PacketDecoder.java:118)
            at com.corundumstudio.socketio.handler.InPacketHandler.channelRead0(InPacketHandler.java:65)
            at com.corundumstudio.socketio.handler.InPacketHandler.channelRead0(InPacketHandler.java:36)
            at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:168)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
            at com.corundumstudio.socketio.transport.WebSocketTransport.channelRead(WebSocketTransport.java:92)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at com.corundumstudio.socketio.transport.PollingTransport.channelRead(PollingTransport.java:109)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at com.corundumstudio.socketio.handler.AuthorizeHandler.channelRead(AuthorizeHandler.java:115)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:108)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
            at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
            at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
            at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
            at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
            at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
            at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
            at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
            at java.lang.Thread.run(Thread.java:745)
    [nioEventLoopGroup-3-8] ERROR com.corundumstudio.socketio.handler.InPacketHandler - Error during data processing. Client sessionId: 3b89da4b-d899-4399-9a32-2d93236b1ad3, data:
    java.lang.NullPointerException
            at com.corundumstudio.socketio.protocol.PacketDecoder.decode(PacketDecoder.java:181)
            at com.corundumstudio.socketio.protocol.PacketDecoder.decodePackets(PacketDecoder.java:118)
            at com.corundumstudio.socketio.handler.InPacketHandler.channelRead0(InPacketHandler.java:65)
            at com.corundumstudio.socketio.handler.InPacketHandler.channelRead0(InPacketHandler.java:36)
            at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:168)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
            at com.corundumstudio.socketio.transport.WebSocketTransport.channelRead(WebSocketTransport.java:92)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at com.corundumstudio.socketio.transport.PollingTransport.channelRead(PollingTransport.java:109)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at com.corundumstudio.socketio.handler.AuthorizeHandler.channelRead(AuthorizeHandler.java:115)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:108)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
            at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
            at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
            at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
            at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
            at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
            at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
            at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
            at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
            at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
            at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
            at java.lang.Thread.run(Thread.java:745)
    

    a) How can I fix this error? b) If several times to upload a large file (2mb) in different pages, server crashes:

    [nioEventLoopGroup-3-8] ERROR io.netty.util.ResourceLeakDetector - LEAK: ByteBuf.release() 
    was not called before it's garbage-collected. 
    Enable advanced leak reporting to find out where the leak occurred. 
    To enable advanced leak reporting, specify the JVM option 
    '-Dio.netty.leakDetectionLevel=advanced' or call ResourceLeakDetector.setLevel()
    

    How can I avoid it?

    bug 
    opened by tselishev-semen 32
  • Binary / byte array messages broken.

    Binary / byte array messages broken.

    Thanks for this awesome framework. I was excited to add the binary support to our product. The problem is I can't get the basic byte[] pushed down based on the demo.

    I'm using 1.7.5 (and even tried snapshot). The BinaryEventLauncher and corresponding binary-event-index.html page.

    1. The client on 'msg' doesn't get invoked unless I use Byte[](instead of the demo code that has byte[]) on the server side. I wouldn't think this matters but for some reason it does. SERVER SIDE BELOW

    2. Even when the client gets called back it throws an "Uncaught RangeError: Invalid typed array length" exception when constructing the Uint8Array(file). CLIENT SIDE BELOW

    SERVER SIDE server.addEventListener("msg", Byte[].class, new DataListener<Byte[]>() { @Override public void onData(SocketIOClient client, Byte[] data, AckRequest ackRequest) {

                //client.sendEvent("msg", data);
                ((ClientOperations) client).sendEvent("msg", data);
            }
        });
    

    CLIENT SIDE (Copied from demo) socket.on('msg', function(file) {

                      var arrayBuffer = new Uint8Array(file).buffer;
                      var blob        = new Blob([arrayBuffer]);
    
                      var imgList = $('ul#img-list');
    
                      var li = $('<li/>').appendTo(imgList);
                      $('<div/>').text(file.name).appendTo(li);
                      var img = $('<img/>').appendTo(li);
    
                      var reader = new FileReader();
                      reader.onload = (function(aImg) {
                        return function(e) {
                          aImg.attr('src', e.target.result);
                          aImg.attr('width', 150);
                        };
                      })(img);
    
                      reader.readAsDataURL(blob);
        });
    
    bug 
    opened by jimmyryan15 31
  • Pooling connections which never timeout

    Pooling connections which never timeout

    Hi, I have problem with connections which stay at transport pooling and never switch to websocket transport.

    If browser have problem with CORS, then I have for 1 user hundreds of connections which never timeout. :/ The connection stay in this state: isChannelOpen:false, getTransport:POLLING.

    You can simulate this problem by CURL - just create a 1. request to socket IO server:

    curl --connect-timeout 2 -L 'http://myserver.com:20443/socket.io/?myparam1=XY&myparam2=123&EIO=2&transport=polling&t=1407835214929-0' > /dev/null
    

    Then when you check connected clients, this connection never timeout :/ This causes, that my socketIO server once a day run out of memory :/

    I found that problem with CORS has only a few of FireFox users. And usually thay have opened FF many days. I didn't find why they have problem with CORS. I will check it. But the main problem are the connections which never timeout :(

    This is a log from browser, where you can see, that connection to "myserver.com" timeout, but the connection on server was created.

    "socket.io-client:url parse http://myserver.com:20443 +0ms" socket.io.js:1258
    "socket.io-client new io instance for http://myserver.com:20443 +0ms" socket.io.js:1258
    "socket.io-client:manager readyState closed +0ms" socket.io.js:1258
    "socket.io-client:manager opening http://myserver.com:20443 +0ms" socket.io.js:1258
    "engine.io-client:socket creating transport "polling" +0ms" socket.io.js:1258
    "engine.io-client:polling polling +0ms" socket.io.js:1258
    "engine.io-client:polling-xhr xhr poll +0ms" socket.io.js:1258
    "engine.io-client:polling-xhr xhr open GET: http://myserver.com:20443/socket.io/?nl_user_id=1286029&nl_phone_extension=20931&EIO=2&transport=polling&t=1409054107046-0 +0ms" socket.io.js:1258
    "engine.io-client:polling-xhr xhr data null +0ms" socket.io.js:1258
    "engine.io-client:socket setting transport polling +2ms" socket.io.js:1258
    "socket.io-client:manager connect attempt will timeout after 20000 +3ms" socket.io.js:1258
    "socket.io-client:manager readyState opening +0ms" socket.io.js:1258
    "socket.io-client:manager connect attempt timed out after 20000 +20s" socket.io.js:1258
    "engine.io-client:socket socket close with reason: "forced close" +20s" socket.io.js:1258
    "engine.io-client:polling transport not open - deferring close +20s" socket.io.js:1258
    "engine.io-client:socket socket closing - telling transport to close +1ms" socket.io.js:1258
    "socket.io-client:manager connect_error +3ms" socket.io.js:1258
    "socket.io-client:manager will wait 1000ms before reconnect attempt +0ms" socket.io.js:1258
    "socket.io-client:manager attempting reconnect +1s" socket.io.js:1258
    "socket.io-client:manager readyState closed +0ms" socket.io.js:1258
    "socket.io-client:manager opening http://myserver.com:20443 +0ms" socket.io.js:1258
    "engine.io-client:socket creating transport "polling" +1s" socket.io.js:1258
    "engine.io-client:polling polling +1s" socket.io.js:1258
    "engine.io-client:polling-xhr xhr poll +21s" socket.io.js:1258
    "engine.io-client:polling-xhr xhr open GET: http://myserver.com:20443/socket.io/?myparam1=XY&myparam2&EIO=2&transport=polling&t=1409054128094-1 +1ms" socket.io.js:1258
    "engine.io-client:polling-xhr xhr data null +0ms" socket.io.js:1258
    "engine.io-client:socket setting transport polling +2ms" socket.io.js:1258
    "socket.io-client:manager connect attempt will timeout after 20000 +3ms"
    
    bug 
    opened by dawe7 26
  • memory leak

    memory leak

    i use netty-socketio 1.6.5 . i found a memory leak ,com.corundumstudio.socketio.transport.XHRPollingClient has not be GC. i use Eclipse Memory Analyzer ,the description is: One instance of "com.corundumstudio.socketio.transport.XHRPollingClient" loaded by "sun.misc.Launcher$AppClassLoader @ 0x7000b7678" occupies 342,686,224 (59.63%) bytes. image

    opened by topiman 25
  • Socketio 1.0 protocol support

    Socketio 1.0 protocol support

    feature 
    opened by mrniko 23
  • flashsocket transport on IE

    flashsocket transport on IE

    How do I enable flash socket transport? I have already set my server add flash socket transport but my client in IE9 cant still connect. What do i need to set in client?

    improvement 
    opened by ilaganra 20
  • Cannot find in maven public repos

    Cannot find in maven public repos

    Hello!

    First of all, thank you for your great work!

    I have a question: is your library available in maven public repositories? I've failed to find it there.

    If yes, could you provide me an address of the repository?

    And if no, could you please publish it?

    opened by deinlandel 20
  • No connect packet returned for polling client, 1.7.0

    No connect packet returned for polling client, 1.7.0

    I'm testing netty-socketio with SocketIO-client 1.0.6, polling transport. The client never gets notification for connect. Then I found the server doesn't send connect packet to client.

    From code, I found it runs into the null block of ClientHead.java:

        public ChannelFuture send(Packet packet, Transport transport) {
            TransportState state = channels.get(transport);
            state.getPacketsQueue().add(packet);
    
            Channel channel = state.getChannel();
            if (channel == null
                    || (transport == Transport.POLLING && channel.attr(EncoderHandler.WRITE_ONCE).get() != null)) {
               // run into the null block
                return null;
            }
            return sendPackets(transport, channel);
        }
    

    Could you please take a look if there's anything wrong ?

    bug 
    opened by sunng87 19
  • PacketEncoder corrupts UTF-8 message

    PacketEncoder corrupts UTF-8 message

    Hi,

    Using SocketIOClient.send("русский"), I receive on client string "русский"

    I think that the problem is in PacketEncoder lines 272-274:

                                String str = b.toString(CharsetUtil.ISO_8859_1);
                                if (enc.canEncode(str)) {
                                    buf.writeBytes(str.getBytes(CharsetUtil.UTF_8));
                                }
    

    the string gets corrupted when converting it with ISO_8859_1 charset, and then it is sent corrupted

    bug 
    opened by evgeny-pasynkov 18
  • have problem with integration with spring?

    have problem with integration with spring?

    I just want to start the netty-socketio server(I use netty-socketio 1.6.0) from a spring service. this code is just have a simple copy from (github:netty-socketio-demo). bean "socketIOConfiguration" is configed by xml file。 when start my project from eclipse .I can find log "SocketIO server started at port: 9092" and show "Client has connected to the server!" from the html demo page(it is also used the netty-socketio-demo index.htm"). and when I send some words from web client page. the server side has no any action found and not send back the words to web client page. I don't know what cause it, please help.thanks very much.

    @Service public class SocketIOService implements Runnable { Configuration config = SpringUtils.getBean("socketIOConfiguration"); SocketIOServer server = new SocketIOServer(config); public SocketIOService() { server.addJsonObjectListener(ChatObject.class, new DataListener() { @Override public void onData(SocketIOClient client, ChatObject data, AckRequest ackRequest) { // broadcast messages to all clients server.getBroadcastOperations().sendJsonObject(data); } }); new Thread(this).start(); } public void run(){ server.start(); }

    }

    <!-- config netty-socketio  -->
    <bean id="socketIOConfiguration" class="com.corundumstudio.socketio.Configuration">
        <property name="hostname" value="localhost" />
        <property name="port" value="9092" />    
    </bean>
    
    opened by ashengwang 18
  • Is this repository still keeping update to `socket.io`?

    Is this repository still keeping update to `socket.io`?

    The last commit is on May 24. Is this repository still keeping update to socket.io's latest version?

    opened by ruojianll 1
  • can I use redission to resolve cluster question

    can I use redission to resolve cluster question

    I want to use netty-socket in cluster environment,but I do not know to make it easy

    opened by yujunchengg 2
  •  Is there a plan to support v3/v4 in the next version?

    Is there a plan to support v3/v4 in the next version?

    v2.x has many inconveniences, such as not supporting esm and vite.
    The new version certainly has better performance.
    By default, npmyarnpnpm installs the latest cli version. Otherwise, the version should be specially declared

    opened by dshvv 0
  • Will  this library support socket.o v3/v4

    Will this library support socket.o v3/v4

    I have angular 11 project and I use socket.io. But I have to use socket.io v3 and newer because Angular 11 doesn't support v2.x. I used this library in backend. But this project doesn't support socket.io 3.x or newer. Accoring to me other guys want it to support v3/v4.

    opened by masa2146 1
  • Expose client auth option

    Expose client auth option

    This fixes issue #503, by exposing a client auth option for TLS connections. When configured, client connection attempts are rejected unless they present a certificate allowed by the trust store. If no trust store is configured, the setting has no effect.

    opened by huws 0
  • ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information

    ByteBuf.release() was not called before it's garbage-collected. See https://netty.io/wiki/reference-counted-objects.html for more information

    image I see the previous issues have explained this memory leakage problem, also provides a solution

    reason: WebSocketTransport line 144 : Packet packet = new Packet(PacketType.MESSAGE); //subType =null PacketEncoder line 288: byte subType = toChar(packet.getSubType().getValue()); //NullPointerException example: fix WebSocketTransport Packet packet = new Packet(PacketType.MESSAGE); packet.setSubType(PacketType.DISCONNECT);

    My version is 1.7.19,I read the source code is to fix this bug,But it's still a memory leak image image Kneel for the big guys to solve the guidance

    opened by 1414215371 0
  • how to upload or download large files

    how to upload or download large files

    i want to upload large files to server from client, now ,i can only upload a byte[] to server, Can the data be called back through the stream?? urgent !!!

    opened by codecodeabc 1
  • Making SocketIO (netty) thread as daemon

    Making SocketIO (netty) thread as daemon

    In com.corundumstudio.socketio.SocketIOServer.class line 198 – 204, when creating NioEventLoopGroup or EpollEventLoopGroup, would it be possible to expose the 2nd parameter where we get to set the ThreadFactory? Maybe this custom ThreadFactory can be passed in via the "Configuration" object.

    The reason to have a custom ThreadFactory is that by default Netty's thread creation does not set the thread as a daemon (like thread.setDaemon(true);). This can cause a non-clean shutdown like described in https://forums.couchbase.com/t/java-client-occasionally-leaks-non-daemon-netty-io-threads-after-shutdown/1252.

    opened by chentv00 0
  • Does the project health?

    Does the project health?

    Really want to know the project is health ?

    opened by liangyuanpeng 2
  • Does NettySocketio support bidirectional authentication?

    Does NettySocketio support bidirectional authentication?

    Does NettySocketio support bidirectional authentication? How do I do it?

    opened by xujingzhou 1
Releases(netty-socketio-1.7.18)
  • netty-socketio-1.7.18(Jun 11, 2020)

    Feature - support for event interceptors which catch all events (thanks to yosiat) Fixed - namespace event broadcasting (thanks to Volodymyr Masliy)

    Source code(tar.gz)
    Source code(zip)
  • netty-socketio-1.7.17(Jan 11, 2019)

    Feature - randomSession setting added to Config object (thanks to yuanxiangz) Fixed - NPE in WebSocketTransport Fixed - NPE & memory leak (thanks to zhaolianwang) Fixed - namespace parsing (thanks to Redliver) Fixed - Redisson 3.9+ compatibility

    Source code(tar.gz)
    Source code(zip)
  • netty-socketio-1.7.14(Feb 26, 2018)

    Feature - added local socket address for the connection (thanks to @SergeyGrigorev)
    Feature - addPingListener method added (thanks to @lovebing)
    Feature - add ThreadFactory for HashedWheelTimer (thanks to @hand515)
    Fixed - changed SO_LINGER to be handled as child channel (not server channel) option (thanks to @robymus)
    Fixed - ByteBuf leak if binary attachments are used
    Fixed - restore session from Cookie (thanks to @wuxudong)
    Fixed - NumberFormatException when b64 is bool value (thanks to @vonway)
    Fixed - data encoding for polling transport

    Source code(tar.gz)
    Source code(zip)
Owner
Nikita Koksharov
Founder and Lead Developer
Nikita Koksharov
A Java library that implements a ByteChannel interface over SSLEngine, enabling easy-to-use (socket-like) TLS for Java applications.

TLS Channel TLS Channel is a library that implements a ByteChannel interface over a TLS (Transport Layer Security) connection. It delegates all crypto

Mariano Barrios 120 Nov 21, 2021
jRT measures the response time of a java application to socket-based requests

jRT Version: 0.0.1 jRT is a instrumentation tool that logs and records networking I/O operations "response times" (applicaion response time if be corr

null 44 Feb 5, 2020
Socket.IO Client Implementation in Java

Socket.IO-Client for Java socket.io-java-client is an easy to use implementation of socket.io for Java. It uses Weberknecht as transport backend, but

Enno Boland 950 Nov 23, 2021
TCP/UDP client/server library for Java, based on Kryo

KryoNet can be downloaded on the releases page. Please use the KryoNet discussion group for support. Overview KryoNet is a Java library that provides

Esoteric Software 1.7k Dec 2, 2021
BAIN Social is a Fully Decentralized Server/client system that utilizes Concepts pioneered by I2P, ToR, and PGP to create a system which bypasses singular hosts for data while keeping that data secure.

SYNOPSIS ---------------------------------------------------------------------------------------------------- Welcome to B.A.I.N - Barren's A.I. Natio

Barren A.I. Wolfsbane 15 Jun 22, 2021
Book Finder application is a client-server application (gRPC) for educational purposes.

Book-Finder Book Finder application is a client-server application (gRPC) for educational purposes. Instalation These projects (Client/Server) are Mav

Mihai-Lucian Rîtan 20 May 31, 2021
Apache Dubbo is a high-performance, java based, open source RPC framework.

Apache Dubbo Project Apache Dubbo is a high-performance, Java-based open-source RPC framework. Please visit official site for quick start and document

The Apache Software Foundation 36.5k Dec 2, 2021
Experimental Netty-based Java 16 application/web framework

Experimental Netty-based application/web framework. An example application can be seen here. Should I use this? Probably not! It's still incredibly ea

amy null 7 Nov 28, 2021
A networking framework that evolves with your application

ServiceTalk ServiceTalk is a JVM network application framework with APIs tailored to specific protocols (e.g. HTTP/1.x, HTTP/2.x, etc…) and supports m

Apple 717 Dec 6, 2021
LINE 3.4k Dec 3, 2021
Netty project - an event-driven asynchronous network application framework

Netty Project Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol serv

The Netty Project 28.1k Dec 5, 2021
The Java gRPC implementation. HTTP/2 based RPC

gRPC-Java - An RPC library and framework gRPC-Java works with JDK 7. gRPC-Java clients are supported on Android API levels 16 and up (Jelly Bean and l

grpc 9.3k Dec 7, 2021
An annotation-based Java library for creating Thrift serializable types and services.

Drift Drift is an easy-to-use, annotation-based Java library for creating Thrift clients and serializable types. The client library is similar to JAX-

null 199 Nov 29, 2021
ssh, scp and sftp for java

sshj - SSHv2 library for Java To get started, have a look at one of the examples. Hopefully you will find the API pleasant to work with :) Getting SSH

Jeroen van Erp 2k Dec 4, 2021
Java library for representing, parsing and encoding URNs as in RFC2141 and RFC8141

urnlib Java library for representing, parsing and encoding URNs as specified in RFC 2141 and RFC 8141. The initial URN RFC 2141 of May 1997 was supers

SLUB 21 Nov 30, 2021
Java API over Accelio

JXIO JXIO is Java API over AccelIO (C library). AccelIO (http://www.accelio.org/) is a high-performance asynchronous reliable messaging and RPC librar

Accelio 72 Sep 8, 2021
Unconventional I/O library for Java

one-nio one-nio is a library for building high performance Java servers. It features OS capabilities and JDK internal APIs essential for making your h

OK.ru 533 Dec 7, 2021
Proteus Java Client

Netifi Proteus Java This project has been moved to https://github.com/netifi/netifi-java Build from Source Run the following Gradle command to build t

netifi-proteus 42 Nov 20, 2020
A Java library for capturing, crafting, and sending packets.

Japanese Logos Pcap4J Pcap4J is a Java library for capturing, crafting and sending packets. Pcap4J wraps a native packet capture library (libpcap, Win

Kaito Yamada 923 Dec 1, 2021