users@grizzly.java.net

R: gws issue #2

From: <rama.rama_at_tiscali.it>
Date: Wed, 13 Apr 2011 10:39:11 +0200 (CEST)

since i have do some test with the other bug with snapshot version, i
can confirm that
this bug persist on 1.9.34-snapshot, while the other
one seems to be fixed!

Also, i have digg a bit more, and if you
comment this line
test.addAsyncFilter(new MyAsyncFilter());
everything
work like a charm.

That's why i think that the error is on async
filter!

And, i have test it with ff4+safari5+chrome, the issue is
present on all the browsers.
(seems that after a couple of refresh it
stop to work, or something like that, in any case, with this test is
quite easy to see it)

best regards

----
Hi all,
another issue with 
GWS is that, when i enable the ASynC stuff, 
after 2-3 req on firefox4 
it just stop to work :)
i can reproduce this 
issue not only with ff4 
but even with other webbrowser.
the issue is 
for sure related to the 
usage of async stuff, and probably related to 
http1.1 (keepalive) 
stuff.
i have see some similar problem in one past 
version of gws, 
unfortunatly i can't remember which one :)
*
public class 
DemoWebServer {
    static final AtomicInteger req = new 
AtomicInteger();
    public static void main(String args[]) {
        GrizzlyWebServer test = new GrizzlyWebServer(7777, 
"/Users/ramarama/IdeaProject/c2w_test/c2w/cert/");
        test.
addGrizzlyAdapter(new MyGrizzlyAdapter(), new String[]{"/"});
        
test.getSelectorThread().setDisplayConfiguration(true);
        test.
getSelectorThread().setCompression("on");
        test.
getSelectorThread().setKeepAliveTimeoutInSeconds(-1);
        test.
getSelectorThread().setMaxKeepAliveRequests(-1);
        test.
addAsyncFilter(new MyAsyncFilter());
        try {
            test.
start();
        } catch (IOException e) {
            e.
printStackTrace();  //To change body of catch statement use File | 
Settings | File Templates.
        }
        while (true) {
            
try {
                Thread.sleep(20500);
            } catch 
(Exception e) {
            }
        }
    }
    static class 
MyAsyncFilter implements AsyncFilter {
        private final 
ScheduledThreadPoolExecutor scheduler =
                new 
ScheduledThreadPoolExecutor(1);
        public Result doFilter(final 
AsyncExecutor asyncExecutor) {
            scheduler.schedule(new 
Callable() {
                public Object call() throws Exception {
                    asyncExecutor.execute();
                    
asyncExecutor.postExecute();
                    return Result.FINISH;
                }
            }, 10, TimeUnit.MILLISECONDS);
            return Result.INTERRUPT;
        }
    }
    static class 
MyGrizzlyAdapter extends GrizzlyAdapter {
        public 
MyGrizzlyAdapter() {
            this.setHandleStaticResources(false);
        }
        public void service(GrizzlyRequest grizzlyRequest, 
GrizzlyResponse grizzlyResponse) {
            try {
                
StringBuilder someJunk = new StringBuilder();
                
grizzlyResponse.setContentType(MimeType.get("html"));
                
someJunk.append("junk<br>");
                for (int i = 0; i < 10; 
i++) someJunk.append(someJunk);
                grizzlyResponse.
getWriter().print(someJunk);
                req.incrementAndGet();
            } catch (IOException e) {
            }
        }
    }
}
Non temiamo alcun confronto: Tiscali ha l'Adsl più veloce d'Italia!
Risparmia con Tutto Incluso Light: Voce + Adsl 20 mega a soli 17,95 € al mese per 12 mesi.
http://abbonati.tiscali.it/telefono-adsl/prodotti/tc/tuttoincluso_light/?WT.mc_id=01fw