Hi
I am also facing the same problem that Chandan had faced.
Then I used RC-1 release of 1.9.17 available at
(
http://download.java.net/maven/2/com/sun/grizzly/grizzly-http-webserver/1.9.17-RC1/).
But, I got the following error
java.lang.NoSuchMethodError:
com.sun.grizzly.util.Grizzly.getRawVersion()Ljava/lang/String;
at com.sun.grizzly.Controller.start(Controller.java:761)
at
com.sun.grizzly.http.SelectorThread.startListener(SelectorThread.java:1206)
at com.sun.grizzly.http.SelectorThread.run(SelectorThread.java:1054)
at
com.sun.grizzly.http.SelectorThread.startEndpoint(SelectorThread.java:1133)
at grizzly.http.test.GrizzlyServer.start(server.java:106)
at grizzly.http.test.server.main(server.java:115)
The controller class invokes “Grizzly.getRawVersion()” inside the start()
method (of com.sun.grizzly.Controller class) which is not available in
com.sun.grizzly.util.Grizzly class in RC1 release.
My sample code is as follows –
:
:
class GrizzlyAsyncProcessor implements AsyncFilter {
public boolean doFilter(final AsyncExecutor executor)
{
final AsyncTask asyncTask = executor.getAsyncTask();
final AsyncHandler asyncHandler = executor.getAsyncHandler();
final ProcessorTask processorTask =(ProcessorTask)
executor.getProcessorTask();
processorTask.getRequest().setNote(1, new Runnable() {
public void run()
{
asyncHandler.handle(asyncTask);
}
});
processorTask.invokeAdapter();
return false;
}
}
class ServiceProcessor implements Adapter {
public void afterService(Request arg0, Response arg1) throws Exception {
}
public void fireAdapterEvent(String arg0, Object arg1) {
}
/**
* This method enqueue the request and response object into the queue.
* @throws IOException
*/
public void service(Request request, Response response) throws
IOException {
System.out.println("RCVD REQ " + request.getContentLength());
String requestURI = request.requestURI().toString();
System.out.println("New incoming request with URI: " + requestURI);
System.out.println("Request Method is: " + request.method());
System.out.println(Thread.currentThread().toString());
response.setStatus(HttpURLConnection.HTTP_OK);
byte[] bytes = "Here is my response text".getBytes();
ByteChunk chunk = new ByteChunk();
response.setContentLength(bytes.length);
response.setContentType("text/plain");
chunk.append(bytes, 0, bytes.length);
OutputBuffer buffer = response.getOutputBuffer();
buffer.doWrite(chunk, response);
response.finish();
}
}
class GrizzlyServer {
SelectorThread selectorThread = null;
/**
* This method will start the Grizzly HTTP Listener.
* @throws Exception
*/
public void start() throws Exception {
System.out.println("inside start");
selectorThread = new SelectorThread();
selectorThread.setPort(7073);
selectorThread.setInet(InetAddress.getByName("localhost"));
selectorThread.setCoreThreads(5);
selectorThread.setMaxThreads(5);
selectorThread.setAdapter(new ServiceProcessor());
final AsyncHandler handler = new DefaultAsyncHandler();
handler.addAsyncFilter(new GrizzlyAsyncProcessor());
selectorThread.setAsyncHandler(handler);
selectorThread.setEnableAsyncExecution(true);
selectorThread.setDisplayConfiguration(true);
selectorThread.setForceKeepAlive(true);
selectorThread.setKeepAliveTimeoutInSeconds(-1);
try {
selectorThread.initEndpoint();
} catch (Exception e) {
System.out.println("HERE IS THE ESCEPTION");
throw e;
}
selectorThread.getSelectorThreadKeyHandler().setTimeout(111);
selectorThread.startEndpoint(); }
}
public class server {
public static void main(String[] args) {
System.out.println("testing server");
GrizzlyServer gs = new GrizzlyServer();
try {
gs.start();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("exc " );
e.printStackTrace();
}
}
}
If I use SNAPHSOT release of 1.9.17 and it is working fine. Does the RC1
version missed something???
Please let me know how to resolve this issue.
Regards
Dipankaj
Oleksiy Stashok wrote:
>
> Hi Chandan,
>
>> My problem has been resolved with 1.9.17-SNAPSHOT binaries (It
>> took
>> quite a bit of time to test).
> Ok, glad to hear that!
>
>> Can I use the 1.9.18 grizzly web server binary
>> in my application. is the 1.9.18 a stable release.
> 1.9.18 is currently in development stage.
> We're trying to release 1.9.17 as stable by fixing some Glassfish
> integration issues, so I'd advice you to use 1.9.17-RC1 for a while,
> until 1.9.17 will be finally released.
>
> Thanks.
>
> WBR,
> Alexey.
>
>>
>> Thanks a lot for all your support.
>>
>> Regards
>> chandan
>>
>>
>> Oleksiy Stashok wrote:
>>>
>>>> I have tried with your solution. But, sometimes I am getting "RST"
>>>> packets from the Grizzly Server.
>>>> In my case there is a non persistent connection between the
>>>> client and
>>>> the server. Will there be new tcp connections everytime for a new
>>>> request.
>>>> Whenever there is a "RST" packet, there is no response from the
>>>> Server. I
>>>> have also noticed that the "service" (I have already placed a sample
>>>> code)
>>>> method in the Grizzly server is not invoked in case of RST packet
>>>> scenarios.
>>>> Kindly guide me to resolve the problem.
>>> Ok, before continuing investigation, can I ask you to try your code
>>> with 1.9.17-SNAPSHOT binaries, to make sure that the issue you see
>>> wasn't fixed [1]
>>> If you still see the issue - the I'd like to ask you send me the
>>> server and client code so I'll be able to reproduce the issue.
>>>
>>> Thank you.
>>>
>>> WBR,
>>> Alexey.
>>>
>>> [1]
>>> http://download.java.net/maven/2/com/sun/grizzly/grizzly-http-webserver/1.9.17-SNAPSHOT/
>>>
>>>
>>>
>>>>
>>>> thanks
>>>> Chandan
>>>>
>>>>
>>>> Oleksiy Stashok wrote:
>>>>>
>>>>> Hi, Chandan,
>>>>>
>>>>> Grizzly, by default, has limited number of HTTP requests it may
>>>>> process on single connection (to avoid some kind of DoS attacks).
>>>>> So, probably, you observe such a behavior because of that
>>>>> mechanism.
>>>>>
>>>>> You can disable it by setting:
>>>>> selectorThread.getMaxKeepAliveRequests(-1);
>>>>>
>>>>> I could be wrong, but let's try that solution and then will see
>>>>> if it
>>>>> helps or not.
>>>>>
>>>>> WBR,
>>>>> Alexey.
>>>>>
>>>>> On Jul 15, 2009, at 8:10 , chandan_evol wrote:
>>>>>
>>>>>>
>>>>>> Hi All,
>>>>>> I am using Grizzly 1.9.15 as a HTTP web server for my
>>>>>> application.
>>>>>> But, whenever the client side sends number of requests (~10
>>>>>> requests
>>>>>> in
>>>>>> second), the application sends RST packets to the client, after
>>>>>> sending FIN
>>>>>> to the client side. This seems that the Grizzly server is dropping
>>>>>> some
>>>>>> requests if it is heavily loaded. Can someone tell me what can
>>>>>> prevent the
>>>>>> Grizzly server to drop requests. The client is maintaining an HTTP
>>>>>> non-persistent connection where everytime connection will be
>>>>>> closed
>>>>>> if there
>>>>>> is a response received for a request.
>>>>>> I would appreciate if someone gives me a solution.
>>>>>>
>>>>>> thanks in advance
>>>>>>
>>>>>> Chandan
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/RST-FIN-sent-from-the-Grizzly-server-tp24492450p24492450.html
>>>>>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/RST-FIN-sent-from-the-Grizzly-server-tp24492450p24497291.html
>>>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/RST-FIN-sent-from-the-Grizzly-server-tp24492450p24531269.html
>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>
>
--
View this message in context: http://www.nabble.com/RST-FIN-sent-from-the-Grizzly-server-tp24492450p24568180.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.