long-polling

How to change this ajax code to long polling [duplicate]

拜拜、爱过 提交于 2019-12-13 00:46:09
问题 This question already exists : How to change from ajax polling to long polling [duplicate] Closed 6 years ago . This is my ajax code so please can anyone tell me how can i change this code to long polling ? Here is my code :- var chat = {} chat.fetchMessages = function () { $.ajax({ url: 'ajax/ajax/chat.php', type: 'POST', data: { method: 'fetch' }, success: function(data) { $('#chats').html(data); } }); } chat.interval = setInterval(chat.fetchMessages, 1000); 回答1: You have to put the next

How to work with long-lasting http requests

[亡魂溺海] 提交于 2019-12-13 00:27:49
问题 I have a long-lasting http request (a lot of computation in the back-end). Currently it's all synchronous, while the server computer, the browser doesn't see the output/result. After a while, the connection is dropped and an timeout error is displayed in the browser. I'd like to return some info to the browser right away, and make it wait for the result. How to achieve this? Please note, that the Java back-end is synchronous. So a solution would require some hack in the servlet/front end

Ajax Long Polling in Java, Spring MVC - session scope issue

狂风中的少年 提交于 2019-12-12 18:09:51
问题 I am trying to implement a long polling mechanism for auto-updating a grid in a project that uses Spring MVC. I am sending an Ajax request from the client and on the server side I enter a while loop until data is found then the data is send back as a response. I need to have another mechanism that stops this operation (that breaks off the loop) when the user changes tab in the application (every tab has a different grid that is auto-updating through long polling. Every tab is handled server

Can long-polling be achieved in Restlet by just making the thread sleep?

瘦欲@ 提交于 2019-12-12 17:24:00
问题 When making a GET request for a particular resource (i.e. ServerResource ) if I put the thread to sleep (to simulate long-polling) what would happen? Does the framework support this? From a Java EE standpoint what are the side-effects? Does it scale well with Tomcat (or any other server?) Has any-one tried implementing long-polling using Restlet by just making the request thread sleep? It seems restlet has no support for comet-style web applications and hence the question of such a hack , so

Keeping connection open in Django without websockets

让人想犯罪 __ 提交于 2019-12-12 04:09:48
问题 I have a mini computer that does not support websockets that I would like to receive push notifications from a server. The issue is that after the client connects to the server, the server responds and then closes the connection. This makes it so the client has to continually reconnect to the server to get new information. Is there a way using Django to allow the connection to be left open and then have the server publish data to the client? 回答1: Django is primarily a request/response

notification and messaging system in javascript and php (without the need of having to install additional software serverside)

泪湿孤枕 提交于 2019-12-11 17:59:08
问题 i'm running a social network with a messaging and notification feature. each time a user sends a message or places a notification for another user, a row is inserted into a table news_updates with the details about the message or notification and all his friends are inserted into the news_seen table. (once the message is read, or the item related to the notification is opened, seen is set to 1, i'm doing this at the end of my callback function for my ajax request - i'm gathering all the

Signalr - websocket successfully connected but client events only called with long pooling

血红的双手。 提交于 2019-12-11 15:47:40
问题 I'm using windows server 2012 and activated websockets on it. When signalr use websockets, the connection is successfully started but no event in client side are called, only if I force signalr to connect with long polling.... Any suggestion ? Thanks 来源: https://stackoverflow.com/questions/30870898/signalr-websocket-successfully-connected-but-client-events-only-called-with-lo

What is the fastest way to see when the last update to MongoDB was made

别说谁变了你拦得住时间么 提交于 2019-12-11 14:34:58
问题 I'm writing a long-polling script to check for new documents in my mongo collection and the only way I know of checking to see whether or not changes have been made in the past iteration of my loop is to do a query getting the last document's ID and parsing out the timestamp in that ID and seeing if it's greater than the timestamp left since I last made a request. Is there some kind of approach that doesn't involve making a query every time or something that makes that query the fastest? I

implementing php long polling

若如初见. 提交于 2019-12-11 13:49:32
问题 I want to use php-long polling in my php script to get the instant display of data when admin changes anything from backend. I have browsed for solutions, But could not find any. I have downloaded php-long-polling- master from github. There , i have a file server.php. There the code is like this <?php /** * Server-side file. * This file is an infinitive loop. Seriously. * It gets the file data.txt's last-changed timestamp, checks if this is larger than the timestamp of the * AJAX-submitted

JMeter - How to handle Longpolling transport method

为君一笑 提交于 2019-12-11 11:04:53
问题 One of the Jmeter requests which I captured contains the 'LongPolling' transport method. So it takes high load time/latency. I don't want to have this much of high latency in the request. How can I handle this situation in JMeter. I have already tried 'bzm-Parallel Controller' and it was not success. 回答1: You can Insert Parent (Right Click) a Runtime Controller with 1 second, it'll execute your long request, but will wait only 1 second and continue to next requests Notice that it'll be marked