Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Restarting timed out AsyncContexts  RSS feed

 
Sreyan Chakravarty
Ranch Hand
Posts: 65
Firefox Browser MyEclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a chat application that uses long-polling to receive chat messages. I am following instructions from the following tutorial in Oracle-:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/async-servlet/async-servlets.html

But now the problem is that when the AsyncContext times out on the server side, what do you do then ? The client has no idea the request has timed out and does not make a new request. So is there anything that can be done to solve this ?

I have tried utilizing the following code in a AsyncListener-:



As you can see I wanted to take the request and response objects and create another AsyncContext and re-add it to the list. But for that I am getting an IllegalStateException as follows-:



So is there anyway I can restart the AsyncContext without informing the client that the request has timed out ?

How do real-life chat applications that use long polling handle this scenario ? Do they inform the client to post another request ? Or can we handle this completely server-side ?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!