Questions tagged [polling]

Polling is actively sampling the status of an external device by a client program as a synchronous activity.

Polling is actively sampling the status of an external device by a client program as a synchronous activity.

Reference:

1451 questions
269
votes
5 answers

How does push notification technology work on Android?

How has Google implemented their push notification feature? Does it work through polling done by a service running in the background or in a different way?
Khawar Raza
  • 15,870
  • 24
  • 70
  • 127
208
votes
9 answers

Detect If Browser Tab Has Focus

Is there a reliable cross-browser way to detect that a tab has focus. The scenario is that we have an application that polls regularly for stock prices, and if the page doesn't have focus we could stop the polling and save everyone the traffic…
Fenton
  • 241,084
  • 71
  • 387
  • 401
114
votes
9 answers

jQuery, simple polling example

I'm learning jQuery, and I'm trying to find a simple code example that will poll an API for a condition. (ie, request a webpage every few seconds and process the results) I'm familiar with how to do AJAX in jQuery, I just can't seem to find the…
Mike
  • 58,961
  • 76
  • 175
  • 221
85
votes
7 answers

Polling API every x seconds with react

I have to monitoring some data update info on the screen each one or two seconds. The way I figured that was using this implementation: componentDidMount() { this.timer = setInterval(()=> this.getItems(), 1000); } …
Eduardo Spaki
  • 1,128
  • 1
  • 8
  • 18
74
votes
5 answers

Using setInterval() to do simplistic continuous polling

For a simple web app that needs to refresh parts of data presented to the user in set intervals, are there any downsides to just using setInterval() to get a JSON from an endpoint instead of using a proper polling framework? For the sake of an…
Sologoub
  • 5,312
  • 6
  • 37
  • 65
57
votes
10 answers

How to wait for a WebSocket's readyState to change

I'm trying to implement a WebSocket with a fallback to polling. If the WebSocket connection succeeds, readyState becomes 1, but if it fails, readyState is 3, and I should begin polling. I tried something like this: var socket = new…
Kendall Frey
  • 43,130
  • 20
  • 110
  • 148
49
votes
5 answers

What's the difference between polling and pulling?

What's the difference between polling and pulling (if any)?
dontWatchMyProfile
  • 45,440
  • 50
  • 177
  • 260
46
votes
4 answers

jQuery AJAX polling for JSON response, handling based on AJAX result or JSON content

I'm a novice-to-intermediate JavaScript/jQuery programmer, so concrete/executable examples would be very much appreciated. My project requires using AJAX to poll a URL that returns JSON containing either content to be added to the DOM, or a message…
Bungle
  • 19,392
  • 24
  • 79
  • 106
43
votes
3 answers

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

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…
Ross
  • 9,652
  • 8
  • 35
  • 35
42
votes
3 answers

Socket connections and Polling. Which is a better solution in terms of battery life?

So... I'm making an application for Android. The application needs to send and receive realtime chat data (needs to be a socket) but it also needs to send commands (which don't as the client knows when it is sending something). I need to know what…
shadrx
  • 941
  • 1
  • 8
  • 22
41
votes
5 answers

ElasticSearch updates are not immediate, how do you wait for ElasticSearch to finish updating it's index?

I'm attempting to improve performance on a suite that tests against ElasticSearch. The tests take a long time because Elasticsearch does not update it's indexes immediately after updating. For instance, the following code runs without raising an…
user916367
40
votes
1 answer

Is SQS short polling ever preferable to long polling?

Amazon SQS supports two modes of polling for available messages: short polling and long polling. With long polling, the consumer specifies a timeout of 1-20 seconds to wait for available messages. According to the documentation: By default, Amazon…
augurar
  • 12,081
  • 6
  • 50
  • 65
40
votes
18 answers

What is wrong with polling?

I have heard a few developers recently say that they are simply polling stuff (databases, files, etc.) to determine when something has changed and then run a task, such as an import. I'm really against this idea and feel that utilising available…
HAdes
  • 16,713
  • 22
  • 58
  • 74
36
votes
2 answers

At what point are WebSockets less efficient than Polling?

While I understand that the answer to the above question is somewhat determined by your application's architecture, I'm interested mostly in very simple scenarios. Essentially, if my app is pinging every 5 seconds for changes, or every minute,…
Ecksters
  • 1,482
  • 2
  • 15
  • 26
27
votes
4 answers

Polling the right way?

I am a software/hardware engineer with quite some experience in C and embedded technologies. Currently i am busy with writing some applications in C# (.NET) that is using hardware for data acquisition. Now the following, for me burning,…
Velocity
  • 375
  • 1
  • 3
  • 8
1
2 3
96 97