comet

Polling, Comet, WebSockets, etc

寵の児 提交于 2019-12-03 00:14:06
I'm needing to build in some pretty agressive "auto refresh" capabilities into a web application. It's kind of a photo gallery and the images are stored on AmazonS3 but the data about the images are stored in our own database. I've played around with polling the server and sending ajax calls to get the updated data. I'm really concerned about the load on the server(s) with this method. At times, the page would need to be updated every 15 to 30 seconds. I've been reading on Comet and I'm just not sold that this "hack" is a great idea. WebSockets would probably help but I'm concerned they are

实现数据库更新时前端页面实时刷新

匿名 (未验证) 提交于 2019-12-03 00:11:01
https://blog.csdn.net/fengguangle/article/details/78019880 问: 难道只能设置定时器每隔一秒通过 Ajax 向后台请求数据来实现吗? 答: 1、 nodejs的 http://socket.io 支持上述 李宏训 所说的三种方式,另外还支持 Flash Socket、隐藏IFrame、JSONP Polling等方式。http://Socket.io提供前端和服务器端的配套机制,并兼容各种浏览器,它的前端js模块会判断浏览器的能力,自适应选择最合适的Comet方式。 2、 我知道有三种方式: 1,ajax短连接:客户端每隔一秒钟发一次请求,服务器收到请求后会立刻返回结果,不管有没有新数据。 2,ajax长连接:客户端发送一次请求,服务器端收到请求后查询有没有新数据,如果没有新数据就阻塞这个请求,直到有新数据或者超时为止。客户端每次收到请求返回结果后立刻再发一次请求。comet貌似就是这个原理。 3,WebSocket:这就不是一个HTTP协议了,而是一个tcp协议,而且Socket这个玩意顾名思义就是一个流了,可以双向操作。缺点是有些浏览器不支持。 对比延迟: 假设网络延迟是m毫秒,那么ajax短连接的延迟在m到1000毫秒之间,另外两种基本只有m毫秒的延迟。 对比资源占用: 应该是1>2>3。但是1和2的比较要看情况

Realtime server push with Socket IO (or Strophe.js), XMPP and Django

泪湿孤枕 提交于 2019-12-02 23:41:44
I have a couple of Android and iOS native mobile application that I wrote which connect directly to an XMPP server that I host. They push and pull realtime data through XMPP. I also use some of the XMPP XEP extensions . For other operations, I have a django application running on the same server which all the mobile applications consume through an HTTP REST interface. I use Celery and Redis for the django side to do some operations asynchronously (like doing heavy batched writes to my db). This all works fine and dandy. Yay. But now I want to write a web front-end to all of this, so I started

Refused to set unsafe header “Origin” when using xmlHttpRequest of Google Chrome

纵然是瞬间 提交于 2019-12-02 22:57:47
Got this error message: Refused to set unsafe header "Origin" Using this code: function getResponse() { document.getElementById("_receivedMsgLabel").innerHTML += "getResponse() called.<br/>"; if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { receiveReq.open("GET", "http://L45723:1802", true, "server", "server123"); //must use L45723:1802 at work. receiveReq.onreadystatechange = handleReceiveMessage; receiveReq.setRequestHeader("Origin", "http://localhost/"); receiveReq.setRequestHeader("Access-Control-Request-Origin", "http://localhost"); receiveReq.timeout = 0; var currentDate =

Implement Comet / Server push in Google App Engine in Python

好久不见. 提交于 2019-12-02 20:23:27
How can I implement Comet / Server push in Google App Engine in Python? Moishe Lettvin We just announced the Channel API to do comet push with App Engine apps: http://googleappengine.blogspot.com/2010/05/app-engine-at-google-io-2010.html If you're at Google IO, I'll be talking about this at 1pm tomorrow (on the APIs track): http://code.google.com/events/io/2010/sessions/building-real-time-apps-app-engine-feed-api.html Here's the YouTube video of the session: http://www.youtube.com/watch?v=oMXe-xK0BWA Hopefully last update! This is now released: code.google.com/appengine/docs/python/channel At

How do I use Comet with Spring MVC?

我们两清 提交于 2019-12-02 17:53:09
I'd like to add some Comet/server push capabilities to a simple web application. I'm having trouble finding up to date information on how to do this. Can anyone point me to some examples, tutorials, blogs, or anything recent that walks you through using Comet with Spring MVC ? In case it matters, I'm using Freemarker to render the views, and JQuery for the JavaScript framework. Aside: I already know all about Lift and its awesome Comet support built-in. This app is a proof of concept that I've already implemented using Lift. Now I'm building it with Spring MVC to compare and contrast. Edit: I

So… ASP.NET MVC and WebSockets?

五迷三道 提交于 2019-12-02 17:45:14
I have an application in MVC 3 and I'm looking to add WebSockets (with fallback to Comet) to it. I've researched a bit and I found out the Comet part is pretty straightforward and I'd much rather do it myself. Just AsyncControllers and a pretty plain bit of js is all that's required to handle those long-lived ajax requests. Now, in the case of WebSocket, things start to get dirty. I've looked at a few libraries, but they mostly seem to set up a web server (therefore needing another host, or port) of their own, and listen to ws protocol requests there. This is the case for instance for

Servlet 3 Async task on Tomcat 7

前提是你 提交于 2019-12-02 17:19:51
I'm trying to implement Simple chat using Servlet 3.0 and Comet pattern based on its async support. I'm inspired by this article: http://www.javaworld.com/javaworld/jw-02-2009/jw-02-servlet3.html?page=3 My servlet looks like this. @WebServlet(name="chatServlet", urlPatterns={"/ChatServlet"}, asyncSupported=true) public class ChatServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { AsyncContext aCtx = request.startAsync(request, response); ServletContext appScope = request.getServletContext(); List

HTML 5 Websockets will replace Comet?

删除回忆录丶 提交于 2019-12-02 17:05:22
It looks like Websockets in HTML 5 will become a new standard for server push. Does that mean the server push hack called Comet will be obsolete? Is there a reason why I should learn how to implement comet when Websockets soon (1-2 years) will be available in all major browsers? Then I could just use Beaconpush or Pusher instead till then right? Daniel Vassallo Does that mean the server push hack called Comet will be obsolete? WebSockets are capable of replacing Comet, AJAX, Long Polling, and all the hacks to workaround the problem when web browsers could not open a simple socket for bi

HTTP Response before Request

孤人 提交于 2019-12-02 16:06:42
My question might sound stupid, but I just wanted to be sure: Is it possible to send an HTTP response before having the request for that resource? Say for example you have an HTML page index.html that only shows a picture called img.jpg . Now, if your server knows that a visitor will request the HTML file and then the jpg image every time: Would it be possible for the server to send the image just after the HTML file to save time? I know that HTTP is a synchronous protocol, so in theory it should not work, but I just wanted someone to confirm it (or not). Raymond Hettinger If someone requests