Atmosphere appends to response instead of sending a new one.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Atmosphere appends to response instead of sending a new one.

mateusz.wiercinski
Hello, so I've managed to fix some of my problems described earlier
(http://java.net/projects/atmosphere/lists/users/archive/2011-09/messag
e/1) and get jQuery Atmosphere plugin partly working in IE by adding to
web.xml the following:
    <init-param>
      <param-name>org.atmosphere.useStream</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>org.atmosphere.useNative</param-name>
      <param-value>true</param-value>
    </init-param>
    <init-param>
      <param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
     
<param-value>org.atmosphere.cache.HeaderBroadcasterCache</param-value>
    </init-param>
Curiously, when I remove useStream, the problem with message caching
returns.
This, however, leads to another 'interesting' behavior. I need to
multiplex my connection so I'm using jfarcand's solution of appending
data to the response and dispatching it to the proper widget on the
client-side. Whenever I try do do:
response.getWriter().write(jsonData);
in my handler, I get:
java.lang.IllegalStateException: STREAM
with no stack trace and of course the response the client receives is
empty (except for the filler junk).
It doesn't matter whether I actually subscribe using streaming, all
that's required is this init-param.
As soon as I remove it, apart from the usual IE problem, another issue
surfaces. The data gets written to the response, but when it's received
it contains all the history. As I'm using JavascriptClientFilter this
means all the previous callbacks are being called! So first publish
works fine, the second calls first and second and so on...
I've tried various combinations of init-params, read through all the
mailing list, even found someone with a similar case but no solution.
Has anyone encountered such problems and could provide assistance?
Thank you in advance

Regards
Mateusz Wiercinski
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Atmosphere appends to response instead of sending a new one.

agi_m
Hi,

seems to me like a problem with the "X-Cache-Date" header parameter. In the last couple of days I was loosing my mind over something very similar. If the client and server are badly out of sync (if the client is more than 5 minutes behind of the servers time), this is what org.atmosphere.cache.HeaderBroadcasterCache does... it returns all of the cached messages. First thing you can do is remove the following init-params from the web.xml to see whether this is the problem:

<init-param>
    <param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
    <param-value>org.atmosphere.cache.HeaderBroadcasterCache</param-value>
</init-param>

If this is the problem, synchronizing client and servers time will solve the problem (hopefully).
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Atmosphere appends to response instead of sending a new one.

mateusz.wiercinski
In reply to this post by mateusz.wiercinski
Hi, thank you for your response. Unfortunately, my problem is a bit
different. Removing the BroadcasterCache apparently changes absolutely
nothing for me. The thing that makes the difference is 'useStream'.
Moreover, on my development machine there is no time difference between
client and server as they both run on my computer.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Atmosphere appends to response instead of sending a new one.

agi_m
Hi,

sorry I couldn't help, it was worth a try.:) Maybe just one more thing to consider... From my experience a lot of strange behaviour can be prevented using the right server. Currently I am using Jetty-7.5.0.v20110901, GlassFish and some other versions of Jetty gave me a lot of headaches.:)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: Re: Atmosphere appends to response instead of sending a new one.

mateusz.wiercinski
In reply to this post by mateusz.wiercinski
I really appreciate your input and give it serious consideration. I'm
actually trying to move away from Jetty and try Tomcat instead. Jetty
is only our dev environment and as such a low priority target. This
also causes a lot of problems, but fortunately at the moment they are
different than before (unless they will resurface later). Hopefully
reliability will be a priority in the next release.
Loading...