long-polling

polling vs long polling

☆樱花仙子☆ 提交于 2019-12-03 05:55:21
问题 I got onto these examples showing polling vs long-polling in javascript, however I do not understand how they differ from one another. Especially regarding the long polling example, how does it keep its connection open? This is what the traditional polling scenario looks like: (function poll(){ setTimeout(function(){ $.ajax({ url: "server", success: function(data){ //Update your dashboard gauge salesGauge.setValue(data.value); //Setup the next poll recursively poll(); }, dataType: "json"}); }

what's the skinny on long polling with ajax and webapi…is it going to kill my server? and string comparisons

℡╲_俬逩灬. 提交于 2019-12-03 03:30:06
I have a very simple long polling ajax call like this: (function poll(){ $.ajax({ url: "myserver", success: function(data){ //do my stuff here }, dataType: "json", complete: poll, timeout: 30000 }); })(); I just picked this example up this afternoon and it seems to work great. I'm using it to build out some html on my page and it's nearly instantaneous as best I can tell. I'm a little worried though that this is going to keep worker threads open on my server and that if I have too big of a load on the server, it's going to stop entirely. Can someone shed some light on this theory? On the back

What is a RESTful way of monitoring a REST resource for changes?

不想你离开。 提交于 2019-12-03 03:03:02
问题 If there is a REST resource that I want to monitor for changes or modifications from other clients, what is the best (and most RESTful) way of doing so? One idea I've had for doing so is by providing specific resources that will keep the connection open rather than returning immediately if the resource does not (yet) exist. For example, given the resource: /game/17/playerToMove a "GET" on this resource might tell me that it's my opponent's turn to move. Rather than continually polling this

long polling netty nio framework java

别说谁变了你拦得住时间么 提交于 2019-12-03 02:50:52
How can I do long-polling using netty framework? Say for example I fetch http://localhost/waitforx but waitforx is asynchronous because it has to wait for an event? Say for example it fetches something from a blocking queue(can only fetch when data in queue). When getting item from queue I would like to sent data back to client. Hopefully somebody can give me some tips how to do this. Many thanks You could write a response header first, and then send the body (content) later from other thread. void messageReceived(...) { HttpResponse res = new DefaultHttpResponse(...); res.setHeader(...); ...

Non-Message Queue / Simple Long-Polling in Python (and Flask)

自古美人都是妖i 提交于 2019-12-03 02:46:37
问题 I am looking for a simple (i.e., not one that requires me to setup a separate server to handle a messaging queue) way to do long-polling for a small web-interface that runs calculations and produces a graph. This is what my web-interface needs to do: User requests a graph/data in a web-interface Server runs some calculations. While the server is running calculations, a small container is updated (likely via AJAX/jQuery) with the calculation progress (similar to what you'd do in a consol with

Asynchronous COMET query with Tornado and Prototype

柔情痞子 提交于 2019-12-03 02:06:00
问题 I'm trying to write simple web application using Tornado and JS Prototype library. So, the client can execute long running job on server. I wish, that this job runs Asynchronously - so that others clients could view page and do some stuff there. Here what i've got: #!/usr/bin/env/ pytthon import tornado.httpserver import tornado.ioloop import tornado.options import tornado.web from tornado.options import define, options import os import string from time import sleep from datetime import

PubNub long polling vs sockets - mobile battery life

 ̄綄美尐妖づ 提交于 2019-12-02 23:01:26
I recently began using PubNub in my iOS app, and am very happy with it. However, I have been looking at the other options available, such as Pusher and Realtime.co, which use Websockets. PubNub, on the other hand, uses long polling. I have done my own little speed comparisons and for my purposes, I find that they are all fast enough. PubNub offers some nice features like message history and a list of everyone in the channel , so barring everything else I am leaning toward them. My question is, should I be concerned with battery life and heavy usage with a long-polling solution like PubNub?

Polling request for updating Backbone Models/Views

安稳与你 提交于 2019-12-02 21:59:10
I need to find a way to update a web App implemented with backbone . The use case will be the following: I have several Views, and each View, or maybe model/collection related to this view, needs to make different polling request to the server at different time for discovering some change. I am wondering what is the most general way to: 1) implement the Traditional Polling Request 2) implement the Long Polling Request 3) implement the HTML5 web socket P.S.: 1) The server is written in PHP. 2) For now I am looking for a solution without using HTML5 WebSockets because maybe with PHP is not so

How do I fix my Cucumber expectation error when polling?

让人想犯罪 __ 提交于 2019-12-02 17:19:54
问题 I have the helper sign_in which signs in a user. I'm trying to use a new approach to make sure that the user signed in using polling: def sign_in(user, password = '111111') # ... click_button 'sign-in-btn' eventually(5){ page.should have_content user.username.upcase } end And here is eventually : module AsyncSupport def eventually(timeout = 2) polling_interval = 0.1 time_limit = Time.now + timeout loop do begin yield rescue Exception => error end return if error.nil? raise error if Time.now >

What is a RESTful way of monitoring a REST resource for changes?

南楼画角 提交于 2019-12-02 16:36:29
If there is a REST resource that I want to monitor for changes or modifications from other clients, what is the best (and most RESTful) way of doing so? One idea I've had for doing so is by providing specific resources that will keep the connection open rather than returning immediately if the resource does not (yet) exist. For example, given the resource: /game/17/playerToMove a "GET" on this resource might tell me that it's my opponent's turn to move. Rather than continually polling this resource to find out when it's my turn to move, I might note the move number (say 5) and attempt to