-
-
Notifications
You must be signed in to change notification settings - Fork 750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Filter not called when message are cached and retrieved] Cast Exception when DefaultBroadcaster tries to send a cached message #986
Comments
Please use 1.0.0.RC1 with UUIDBroadcasterCache. This issue has been already fixed. |
Thanks for the reply. I couldn't find 1.0.0.RC1 and just downloaded 1.1.0-SNAPSHOT from the repository but the exception is still happening. |
Do you have BroadcastFilter defined by any chance? If yes, make sure you set the set the BroadcasterCache stategy to beforeFilter, as described here |
I'm using the TrackMessageSizeInterceptor instead of the filter and the BroadcasterCache.strategy set to beforeFilter |
Sorry to bother again but in AbstractReflectorAtmosphereHandler.onStateChange there is a check in the type of the message but maybe the generic is missing (List <String>) if (message instanceof List) {
for (String s : (List<String>) message) {
if (isUsingStream) {
r.getOutputStream().write(s.getBytes(r.getCharacterEncoding()));
r.getOutputStream().flush();
} else {
r.getWriter().write(s);
r.getWriter().flush();
}
}
} else {
if (isUsingStream) {
r.getOutputStream().write(message.toString().getBytes(r.getCharacterEncoding()));
r.getOutputStream().flush();
} else {
r.getWriter().write(message.toString());
r.getWriter().flush();
}
}
} |
I don't think that's the issue. The issue is your object, sport.model.Match, et propagated inside Atmosphere instead of a String representation. Where the Match -> String conversion occurs without broadcasterCache? |
It makes sense what you say. I'm using a filter (jsonOutputFilter) public void createChannel(String channelId) {
|
And if it helps , this is the filter: import org.atmosphere.cpr.BroadcastFilter; import sport.model.Action; |
No way , I've changed the TrackMessageSizeInterceptor for the TrackMessageSizeFilter and called my JSONOutputFilter from the web.xml but the result is the same. This is my new configuration: <init-param> but unfortunately the result is the same |
Hard to see what wrong...for sure the wrond message is queue to be writen. Does it work without BroadcasterCache installed? |
yes, without the Cache I can broadcast messages and when I set the client offline I get a WARN (see below) but not a cast exception when sending a new message Warning when disconnecting the browser: |
It's late night here in Europe, I have to stop. Tomorrow I'll add traces to the DefaultBroadcaster to see what's going on and let you know. |
I've done one more test that might help. When I want to delete something from the customers' screens I'm broadcasting a String message that doesn't need to be converted to JSON. In this case, when I reconnect the client after being offline I got no cast exception. I think this has nothing to do with the issue but it looks like the cached message is pushed twice and the second time is getting the result of the first as input. It maybe the expected behaviour as the cached message will also be cached when sent.
|
The problem is that in DefaultBroadcaster.checkCachedAndPush() when the cache strategy is STRATEGY.BEFORE_FILTER only the PerRequestFilters are applied and my JSONOutputFilter was a standard filter. I don't know if this should be the proper behaviour or also the standard filters have to be applied. After changing it to a PerRequestFilter the cached messages are pushed to the client without problems. Still there is a remaining question. Cached Messages are broadcast twice and if you check the traces of my previous comment the 2nd time the message is sending the size twice. Is this the correct behaviour? Do I have something doggy in my configuration? Thanks again |
Sound like a bug to me for the filter not being invoked. I will do some testing on my side...for the double message, I will need a test case. Thanks!! |
OK fixed the first issue, e.g filters not being invoked. Can you file an issue for the second problem? This one is harder to reproduce. Thanks for your patience! |
No problem, I'll try to find a pattern |
version:1.1.0.beta3
transport: long-polling
server: tomcat 6.0.36
browser: Firefox 19.0.2
log-extract-1 (disconnect client with no error):
log-extract-2 (reconnect client after a message has been broadcasted):
The text was updated successfully, but these errors were encountered: