Persistent http connection from Java server

2019-06-09 16:29发布

问题:

I want to create a persistent connection between Java spring server and Android client.

What I need is sort of a push mechanism with a persistent (long-lived HTTP) connection that will stream all the information from server to the client once they are available.

Are there any available frameworks that would support that, Java Spring preferably. Tutorials or documents that will help me implementing this.

回答1:

Well you can start here to learn about the general ways to accomplish that.

Some example technologies are:

  • Google App Engine Channel API
  • HTML5 Websockets
  • Blaze DS


回答2:

Long-lived HTTP connections and WebSockets are generally more suited to web apps when it comes to 'push'.

If you don't mind some work on the server side, a persistent socket is definitely the most battery friendly way.

Here's a good start: http://devtcg.blogspot.com/2009/01/push-services-implementing-persistent.html