• Post Reply Bookmark Topic Watch Topic
  • New Topic

Best way to keep a long polling connection open  RSS feed

Ranch Hand
Posts: 65
Firefox Browser MyEclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a chat application in Java Servlets that uses long-polling to get chat notifications from the server. I have to persist the connection indefinitely without using something like WebSockets. I am using an AsyncListener to listen for the TimeOut event, if it occurs it sends a text string back to the client "Keep-Alive" and the client makes another request. And the process continues until the client is no longer receiving any messages.

Here is a portion of the code-snippet I am using-:

Now I am sure that there is a better way to keep the connection open, something a little more optimized. What would that be ? What are the considerations that need to be taken for bidirectional HTTP ?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!