Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Server push using Polling
Server push using Polling [message #778561] Fri, 13 January 2012 09:55 Go to next message
Amandeep Chahal is currently offline Amandeep ChahalFriend
Messages: 85
Registered: September 2011
Location: India
Member
Hi,
In my RAP application I'm trying to detect browser close events using the Polling mechanism i.e injecting a client side js to regularly send requests to the server. On the server I have code to keep track of these requests, and once these requests stop coming, I know that the browser has been closed.

The client side js that I inject is
  
String code =   "window.setInterval( function() {\n"
                + "  org.eclipse.swt.Request.getInstance().send();\n"
                + "}, 10000 );"; // polling interval in ms
  JSExecutor.executeJS( code );



Now I have 2 issues with this :

1. When I have a user request that takes more time than the interval I have set for the polling request from the client, this logic fails.
So for example if I set the interval to say 40 seconds and I have a request that is taking 60 seconds, then because the client has not sent any request during these 60 seconds, my session termination code is executed.
Looking at the Request.js I see that the maximum capacity for the request queue is set to 1. Hence when one request is under process, no other request can be made from the client.

2.
If the browser for some reason hangs for more than 40 seconds the logic fails for the same reason again.

How do I solve this?
Re: Server push using Polling [message #778601 is a reply to message #778561] Fri, 13 January 2012 13:44 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Hi,

UI requests in RAP are supposed to return immediately. If you have
requests that take 60 seconds, than something is really wrong. Do you
call long-running operations in an event listener? If so, you should
consider to execute those operations in a background thread and let the
request return. You can activate a UI callback to let the client
automatically refresh when the operation is done.

Regarding your second question: Why would a browser hang for 40 seconds?


Regards, Ralf


--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Server push using Polling [message #778611 is a reply to message #778601] Fri, 13 January 2012 14:06 Go to previous messageGo to next message
Amandeep Chahal is currently offline Amandeep ChahalFriend
Messages: 85
Registered: September 2011
Location: India
Member
The UI operations normally do not take that long, but if the user tries to deal with a lot of data at the same time (user is allowed to do that in our application), then the requests may take longer. That's the reason the operations have not been executed as background threads. Moreover, ours being a single sourced RCP/RAP application it would be difficult to make such changes. Is there any other way to fix this?

For the second question, browser hang would depend on the user's system utilization. For example you have a very heavy script running on one of the tabs may hang the browser for a while.

Thanks.
Re: Server push using Polling [message #778613 is a reply to message #778601] Fri, 13 January 2012 14:06 Go to previous messageGo to next message
Amandeep Chahal is currently offline Amandeep ChahalFriend
Messages: 85
Registered: September 2011
Location: India
Member
The UI operations normally do not take that long, but if the user tries to deal with a lot of data at the same time (user is allowed to do that in our application), then the requests may take longer. That's the reason the operations have not been executed as background threads. Moreover, ours being a single sourced RCP/RAP application it would be difficult to make such changes. Is there any other way to fix this?

For the second question, browser hang would depend on the user's system utilization. For example you have a very heavy script running on one of the tabs may hang the browser for a while.

Thanks.
Re: Server push using Polling [message #779569 is a reply to message #778613] Mon, 16 January 2012 04:10 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 221
Registered: February 2011
Senior Member
The way I did it was to provide a little clock in the status bar. Its updated once per minute and because we needed global UICallback's for another purpose it works quite well. Session timeouts are set very short (eg: 5 minutes) and are kept alive by the UICallback. That said you should be running all large operations in a background thread, even more so for an RCP application. Have a look at the jobs API. It works pretty well. There is also the ProgressMonitorDialog.
Re: Server push using Polling [message #779571 is a reply to message #778613] Mon, 16 January 2012 04:10 Go to previous message
Chris Fairhall is currently offline Chris FairhallFriend
Messages: 221
Registered: February 2011
Senior Member
The way I did it was to provide a little clock in the status bar. Its updated once per minute and because we needed global UICallback's for another purpose it works quite well. Session timeouts are set very short (eg: 5 minutes) and are kept alive by the UICallback. That said you should be running all large operations in a background thread, even more so for an RCP application. Have a look at the jobs API. It works pretty well. There is also the ProgressMonitorDialog.
Previous Topic:Request the footer or fix row implement for tableviewer?
Next Topic:1.4 entrypoint not initialized with RAP 1.5
Goto Forum:
  


Current Time: Thu Apr 25 09:54:23 GMT 2024

Powered by FUDForum. Page generated in 0.03838 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top