diff --git a/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java b/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java index f777468..0a9227e 100644 --- a/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java +++ b/src/main/java/com/corundumstudio/socketio/SocketIOChannelInitializer.java @@ -22,6 +22,7 @@ import io.netty.channel.ChannelPipeline; import io.netty.handler.codec.http.HttpObjectAggregator; import io.netty.handler.codec.http.HttpRequestDecoder; import io.netty.handler.codec.http.HttpResponseEncoder; +import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; import io.netty.handler.ssl.SslHandler; import java.security.KeyStore; @@ -59,6 +60,7 @@ public class SocketIOChannelInitializer extends ChannelInitializer impl public static final String SOCKETIO_ENCODER = "socketioEncoder"; public static final String WEB_SOCKET_TRANSPORT = "webSocketTransport"; + public static final String WEB_SOCKET_AGGREGATOR = "webSocketAggregator"; public static final String XHR_POLLING_TRANSPORT = "xhrPollingTransport"; public static final String AUTHORIZE_HANDLER = "authorizeHandler"; public static final String PACKET_HANDLER = "packetHandler"; @@ -138,27 +140,27 @@ public class SocketIOChannelInitializer extends ChannelInitializer impl addSslHandler(pipeline); addSocketioHandlers(pipeline); } - + /** * Adds the ssl handler - * + * * @return */ protected void addSslHandler(ChannelPipeline pipeline) { - if (sslContext != null) { + if (sslContext != null) { SSLEngine engine = sslContext.createSSLEngine(); engine.setUseClientMode(false); pipeline.addLast(SSL_HANDLER, new SslHandler(engine)); } } - + /** * Adds the socketio channel handlers - * + * * @param pipeline */ protected void addSocketioHandlers(ChannelPipeline pipeline) { - pipeline.addLast(HTTP_REQUEST_DECODER, new HttpRequestDecoder()); + pipeline.addLast(HTTP_REQUEST_DECODER, new HttpRequestDecoder()); pipeline.addLast(HTTP_AGGREGATOR, new HttpObjectAggregator(configuration.getMaxHttpContentLength())); pipeline.addLast(HTTP_ENCODER, new HttpResponseEncoder()); diff --git a/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java b/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java index 4387062..98aa67a 100644 --- a/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java +++ b/src/main/java/com/corundumstudio/socketio/transport/WebSocketTransport.java @@ -29,6 +29,7 @@ import io.netty.handler.codec.http.QueryStringDecoder; import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame; import io.netty.handler.codec.http.websocketx.TextWebSocketFrame; +import io.netty.handler.codec.http.websocketx.WebSocketFrameAggregator; import io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker; import io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerFactory; import io.netty.util.ReferenceCountUtil; @@ -41,6 +42,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.corundumstudio.socketio.Configuration; +import com.corundumstudio.socketio.SocketIOChannelInitializer; import com.corundumstudio.socketio.Transport; import com.corundumstudio.socketio.handler.AuthorizeHandler; import com.corundumstudio.socketio.handler.ClientHead; @@ -159,6 +161,9 @@ public class WebSocketTransport extends ChannelInboundHandlerAdapter { log.error("Can't handshake " + sessionId, future.cause()); return; } + + channel.pipeline().addBefore(SocketIOChannelInitializer.WEB_SOCKET_TRANSPORT, SocketIOChannelInitializer.WEB_SOCKET_AGGREGATOR, + new WebSocketFrameAggregator(configuration.getMaxFramePayloadLength())); connectClient(channel, sessionId); } });