users@grizzly.java.net

Re: Quickest way to kill a connection

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Wed, 28 Nov 2007 13:35:19 -0500

Alan Williamson wrote:
> Its me again!
>
> I am getting on great guns you'll be pleased to know.

:-) :-)

>
> Just a quick one today ... as per the subject, what is the quickest way
> to kill off a client.
>
> I have tried:
>
> res.reset();
> res.finish();
>
> I have also tried throwing an exception.
>
> I want to kill off the connection completely; waste no more bandwidth on
> the person. As you can understand this is part of the spam prevention,
> the very reason, i am using grizzly in the first place.

Have you implemented a ReadFilter to throttle requests? Because inside
that class, you might just set:

ctx.getSelectorHandler().getSelectionKeyHandler().cancel(ctx.getSelectionKey());

If you are inside Adapter, try to do

res.addHeader("Connection:","close");

or

res.setStatus(408); //Or 404

Let me know if that doesn't work.

Thanks

-- Jeanfrancois



>
> I read in the HTTP header, and once i have that, i can make a decision
> as to whether or not we service them. If we don't, we sandbox them for
> a while and prevent them from connecting.
>
> In the "servlet" days, we would simply close the outputstream.



>
> Please advise.
>
> thanks
>
> a
>