Atmosphere / atmosphere

Event Driven WebSockets Framework with Cross-Browser Fallbacks
http://async-io.org/
3.69k stars 749 forks source link

[Gwt1] [1.0.18] Response over websocket is broken #1493

Closed shaileshkulkarni closed 10 years ago

shaileshkulkarni commented 10 years ago

Hi,

I am using Atmosphere with GWT extenstion (1.0.18) to send events to client. The response payload is dynamically created and has payload size larger than 8192 bytes.

From the Chrome's developer tool, I saw that the websocket frame of length 8192 is sent from the server but there was no default delimeter (@##@) and it was broken. After that another frame was received with the remaining part of it, having delimiter.

Due to this broken packet, GWT Atmosphere extension could not serialize it and I got SerializationException. The default action GWT Atmosphere extension takes is to close the connection.

Please find client side debug logs as,

19:8:39,266 AtmosphereListener : onError : Exception : com.google.gwt.user.client.rpc.SerializationException: com.google.gwt.core.client.JavaScriptException: (SyntaxError): Unexpected token ILLEGAL
 stack: SyntaxError: Unexpected token ILLEGAL
    at PZf (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:9809:28)
    at $md (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:8834:54)
    at Fwg (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:9124:155)
    at eyg (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:10033:154)
    at Object.pyg [as cm] (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:11176:28112)
    at WebSocket.<anonymous> (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:9334:169)
    at OHe (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:6031:30)
    at RHe (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:9536:62)
    at WebSocket.<anonymous> (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:7684:46) : Message : com.google.gwt.core.client.JavaScriptException: (SyntaxError): Unexpected token ILLEGAL
 stack: SyntaxError: Unexpected token ILLEGAL
    at PZf (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:9809:28)
    at $md (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:8834:54)
    at Fwg (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:9124:155)
    at eyg (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:10033:154)
    at Object.pyg [as cm] (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:11176:28112)
    at WebSocket.<anonymous> (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:9334:169)
    at OHe (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:6031:30)
    at RHe (http://148.147.208.92:8080/inyama/2A1F6BC8ACF0E72AB2FE4D987887FA7B.cache.html:9536:62)
    at WebSocket.<anonymous> (http://148.147.208.92:8080/i

I was looking for the documentation if there is any size limit on the response to be sent, I went through this link https://github.com/Atmosphere/atmosphere/wiki/Streaming-websockets's-message-with-WebSocketStreamingProtocol

It's mentioned that "By default, Atmosphere's WebSocket implementation will buffer websocket message of size up to 2 MG". I tried joining two frames received and found that the size of whole packet is around 9 KB.

My "atmosphere.xml" is as,

<atmosphere-handlers>
    <atmosphere-handler context-root="/EventsStreaming" class-name="com.avaya.server.rocket.EventStreamingAtmosphereHandler">
        <property name="heartbeat" value="15000"/>
    </atmosphere-handler>   
    <applicationConfig>
          <param-name>org.atmosphere.cpr.broadcaster.shareableThreadPool</param-name>
          <param-value>true</param-value>
     </applicationConfig>
     <!--
    <applicationConfig>
        <param-name>org.atmosphere.cpr.recoverFromDestroyedBroadcaster</param-name>
        <param-value>true</param-value>
    </applicationConfig> -->

    <applicationConfig>
        <param-name>org.atmosphere.cpr.broadcasterClass</param-name>
        <param-value>org.atmosphere.util.SimpleBroadcaster</param-value>
    </applicationConfig>
</atmosphere-handlers>

I had created bug on tomcat 7, https://issues.apache.org/bugzilla/show_bug.cgi?id=56187 but they said that it needs to be handled at the application side. (Atmosphere).

To reproduce the issue try to send big payload message larger than 8192 bytes over websocket transport for Atmosphere GWT 1.x and the received frame is cut to 8192 bytes.

If the server is not capable of controlling the frames then I think client should be able to aggregate frames and create the message payload.

jfarcand commented 10 years ago

Since Atmosphere 1.0.x needs a support contract for fixes, I recommend you either upgrade Atmosphere, or visit Async-IO.org. I don't think a fix can be made for that, do I'm closing the issue as won't fix. Thanks for filling it we can use it as a reference.