Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Long polling
30-01-2012, 07:25 AM
Post: #1
Long polling
I noticed some recent changes in the codebase to support long polling. I've done a bit of web searching to get a basic understanding of what long polling is, but I'm not clear on how it's used in the context of ohNet. A brief explanation would be much appreciated.

Find all posts by this user
30-01-2012, 03:06 PM
Post: #2
RE: Long polling
In short, long polling shouldn't be of much interest to you.

In more detail...
UPnP defines an eventing mechanism for servers to inform clients of changes to evented state variables in a service. This involves the client running a tcp server which the server connects to whenever it has an update to report. This doesn't work for JavaScript clients which are unable to run such a server.

Our normal solution to this is to run a WebSocket server inside the device stack. The JS control point's SubscriptionManager class connects to this and presents a subscription-like API to our generated JS proxies. This works nicely for browsers which support WebSockets but adoption of this protocol is proving slow so we need a solution for slower moving browsers. Long polling provides this solution.

If the JS SubscriptionManager is unable to connect to our WebSocket server, it falls back to using a SubscriptionLongPoll service. This service allows clients to subscribe to a number of services then call a GetPropertyUpdates action which will complete as soon as updates from one or more of these services are available. If there are no updates after 30s, the action completes with an empty updates string.

We'll support both WebSockets and long polling for the forseeable future. Device stack clients (such as MinimServer) probably won't need to care about this unless they offer rich presentation pages which make use of ohNet JS APIs. Any device which expects to have ohNet-aware web clients should set the number of web socket threads in InitParams (it defaults to 0, meaning no WebSocket support). Any device which expects to have a number of simultaneous ohNet-aware web clients should consider increasing the number of device server threads.
Find all posts by this user
31-01-2012, 11:00 AM
Post: #3
RE: Long polling
Thanks very much for this explanation. I might need a web GUI at some point, so I'll revisit this topic when that happens.

Find all posts by this user

Forum Jump: