Search code examples
server-sent-eventsatmosphere

Atmosphere fallback not working?


I am new to atmosphere. So far I have managed to add atmosphere to my existing Tomcat 8 + Spring + Struts2 web application. I used the current version (atmosphere-runtime 2.4.24, atmosphere-spring 2.4.20 and atmosphere.js 2.3.5).

For some sort of simple status page I have already managed to get the SSE transport to work. Using Google Chrome or Mozilla Firefox this works really excellent. I love it! After having implemeted this I wanted to check the fallback for the browsers uncapable of SSE (Internet Explorer and Edge). In the client logs I can see that atmosphere corretly detects absence of the SSE feature and uses the fallback:

    Server Side Events(SSE) is not supported, using request.fallbackTransport (long-polling)
atmosphere.js (3272,21)

 Thu May 24 2018 08:54:28 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 2
atmosphere.js (3272,21)

 Thu May 24 2018 08:54:28 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 3
atmosphere.js (3272,21)

 Thu May 24 2018 08:54:28 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 4
atmosphere.js (3272,21)

 Thu May 24 2018 08:54:29 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 2
atmosphere.js (3272,21)

 Thu May 24 2018 08:54:29 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: Firing onOpen
atmosphere.js (3272,21)

 Atmosphere connected using long-polling
utils.js (879,3)

 Thu May 24 2018 08:54:29 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: Firing onOpen
atmosphere.js (3272,21)

 Thu May 24 2018 08:54:29 GMT+0200 (Mitteleuropäische Sommerzeit) Atmosphere: ajaxRequest.onreadystatechange, new state: 3
atmosphere.js (3272,21)

But even though I can debug the server-side and see the message being written to the AtmosphereResource no data reaches the client. This is how I initialize the atmosphere connection on client-side:

request = { 
        url: '<s:url value="/public/sse/ci" />',
        contentType: "application/json",
        method: 'POST',
        logLevel: 'debug',
        transport: 'sse',
        reconnectInterval: 5000,
        fallbackTransport: 'long-polling'
    };

Can anyone give me a hint for the right direction?

Kind regards,

Sebastian


Solution

  • Okay.

    Finally I got it working. Like in this stackoverflow question I had added the TrackMessageSizeInterceptor in my server configuration but not in the client configuration. Maybe someone else comes here to read the answer.