3

I followed this tutorial and implemented a simple chat application. I'm testing it both in latest Mozilla Firefox and Google Chrome browsers.

My main concern is that the messaging exchange does not seem to happen in real time. Even though the all the server processing happens in less than a second from the request, the browser gets the response just after the AsyncContext timeout is exceeded.

Even is the default 10 seconds or a custom value added through AsyncContext.setTimeout() the time of response is the same with the timeout. Should this be the expected behaviour? Is there a way to force the server to send the response as soon as it is ready and not wait the hole timeout interval?

4

1 に答える 1

3

complete非同期コンテキストを忘れている可能性があります。Java 6ドキュメント:http ://docs.oracle.com/javaee/6/api/javax/servlet/AsyncContext.html#complete ()

watcherExecutor.execute(new Runnable(){
                        public void run() {
                           // publish a new bid event to a watcher
                           aCtx.getResponse().getWriter().print("A new bid on the item was placed. The current price ..., next bid price is ...");
                           aCtx.complete();
                        };
                     });
于 2012-08-21T10:22:40.720 に答える