Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Restarting timed out AsyncContexts

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-:

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 ?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic