|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Possible DWR issue with reverse ajax alarmGreetings,
I use dwr-2.0.4 in my web application. I have a problem with reverse ajax requests. Sometimes data from server comes to the client side after long time delay. I set dwr.engine._maxPollRetries property to 5, so if reverse ajax fails, it will be restarted in 10 seconds. I found that if we have some scripts on server side to be sent to the client after reverse ajax request fails, client receives that scripts at the end of the next reverse ajax request (60 seconds after request starts), but not immediately. I use Firefox with Firebug plugin for testing. Scenario: 1) wait for reverse ajax request (use firebug for viewing); 2) press "Esc" button in Firefox to abort reverse ajax request (next reverse ajax request will be sent in 10 seconds); 3) send simple ajax request to server to fire some timer for 3 seconds; 4) after 3 seconds server send some data to client using reverse ajax; Result: I saw data on client side after 67 seconds ((10 - 3) + 60) but not after 7 seconds (10 -3). I studied dwr-2.0.4 source code and found some strange behavior. In PollHandler if reverse ajax request comes and we already have waiting scripts on server side, scripts are added to the conduit but OutputAlarm doesn't generate raiseAlarm signal. So in such case if no more data comes to server we must waiting for 60 seconds (max waiting time) then reverse ajax wakes up and sends response to the client. I modified OutputAlarm class. I added check for waiting scripts in setAlarmAction method. Now if server has waiting scripts then addScript method of AlarmScriptConduit class is called to generate raiseAlarm signal. After that sleeper never goes to sleep and response immediately will be sent to client. So I change setAlarmAction method of OutputAlarm class from: public void setAlarmAction(Sleeper sleeper) { try { scriptSession.addScriptConduit(conduit); } catch (IOException ex) { log.warn("Error adding monitor to script session", ex); } super.setAlarmAction(sleeper); } to: public void setAlarmAction(Sleeper sleeper) { try { super.setAlarmAction(sleeper); scriptSession.addScriptConduit(conduit); if (scriptSession.hasWaitingScripts()) { conduit.addScript(new ScriptBuffer()); } } catch (IOException ex) { log.warn("Error adding monitor to script session", ex); } catch (MarshallException e) { log.warn("Error generating raiseAlarm signal", e); } } What do you think about it? Is it dwr issue? Thanks in advance. -- Best regards, Anton Grinenko, ARDAS group (http://www.ardas.dp.ua) --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Possible DWR issue with reverse ajax alarmHi, Thanks for the report an for digging into this. I think the correct fix is slightly different: In setAlarmAction, the call to scriptSession.addScriptConduit(conduit); effectively does what you are doing manually, the problem is that there is no sleeper set. So the right thing to do is to move super.setAlarmAction(sleeper); above the try/catch block. What do you think? Joe. On Tue, Jul 1, 2008 at 11:26 AM, Anton Grinenko <anton.grinenko@...> wrote: Greetings, |
|
|
Re: Possible DWR issue with reverse ajax alarmYes, I agree with you. Thanks for help
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
| Free Forum Powered by Nabble | Forum Help |