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 ?