dev@grizzly.java.net

Re: still some help for grizzlywebserver

From: rama <rama.rama_at_tiscali.it>
Date: Mon, 5 Jan 2009 17:53:14 +0100

>>
>>
>> 1) i use this constructor
>>
>> *****
>> public GrizzlyWebServer(int port, int maxThreads, String
>> webResourcesPath,
>> boolean secure) {
>> createSelectorThread(port, maxThreads, secure);
>> this.webResourcesPath = webResourcesPath;
>> }
>> *****
>>
>> to create the webserver (cos i need ssl support)
>> specify maxThreads > 5 doesn't add any worker :S
>>
>> Basically, i want to have more worker that will be able to serve
>> the client, so if a client
>> take a lot of time to get the response, other will not be blocked.
>>
>> Also, a nice things, that probably is there but i don't get, is to
>> create
>> worker thread based on the load or the real needing.
>>
>> How i can add this?
> Seems this is bug, can you pls. file an issue for that on http://
> grizzly.dev.java.net/issues/ ?
>

DONE


>> 2) async write
>> ****
>> public void useAsynchronousWrite(boolean asyncWrite){
>> st.setAsyncHttpWriteEnabled(asyncWrite);
>> }
>> ****
> Async write currently doesn't work with ssl, just with plain HTTP.
> Can you pls. try plain HTTP to be sure the problem is just with HTTPS?
>

the problem was found on http not https.
I will leave the problem description there as a reference


>>
>> if i turn this on, i got some wired response :(
>> basically the client is a flash program, that do some loadmovie.
>> Sometimes the flash get corrupted in the transfer and flash crash
>> with pain and suffering.
>> removing the asyncwrite fix the problem :) honestly i don't know
>> how i can debug it :(
>>
>> but i have some info to give to you :D
>>
>> this is what i do to write the response, i have 2 different case
>> a) the request is a POST, i parse the request and generate an XML
>> as a response then, to write it
>> ****
>> httpResp.setHeader("Set-Cookie", "SID="+session.sid);
>> httpResp.setCharacterEncoding("utf-8");
>> httpResp.setStatus(200);
>> httpResp.setContentType("text/xml");
>> httpResp.getWriter().print(res.asXML());
>> ****
>>
>> res.asXML return a string, so for me is ok, isn't it??
>> I haven't tested too much this part with asyncwrite, because the
>> flash crash before (while loading a swf)
>>
>> b) the request is a GET, so i send out a file
>> i don't use staticresadapter, for some odd reason i need to get
>> the file in 2 different place (i know that this is horrible, but
>> at the moment is the only way)
>> and, to write the file out, i do
>> ****
>> //SEND FILE
>> res.setStatus(200);
>>
>> int dot = resource.getName().lastIndexOf(".");
>> if (dot > 0) {
>> String ext = resource.getName
>> ().substring(dot + 1);
>> String ct = MimeType.get(ext);
>> if (ct != null) {
>> res.setContentType(ct);
>> }
>> } else {
>> res.setContentType(MimeType.get
>> ("html"));
>> }
>>
>> long length = resource.length();
>> res.setContentLengthLong(length);
>>
>> fis = new FileInputStream(resource);
>> byte b[] = new byte[8192];
>> while (fis.read(b) > 0) {
>> res.getStream().write(b);
>> }
>> res.getStream().flush();
>> ****
>>
>> keep in mind that res is a grizzlyresponse in this example.
>> could this piece of code generate some problem with asyncwrite?
>