Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Limiting connections

Hi,

I'm using Jetty with a custom Connection/ConnectionFactory.  

I want to impose a connection limit and I don't want to abruptly close the connection without providing an error to the client.  Rather, I'd like to send an error message and then close the connection.  But I can't send the error response until I have received the first request.  I don't have control over when the client sends the first request but it would typically be shortly after the connection is established. 

What is the best way to do this? 

One idea I have is:
(1) when the connection is created, schedule a task that will come back and close it within some short period (a few seconds)
(2) if within that period, I get a request, send the error and then close the connection on the endPoint() write callback.

Thanks,
Josh




Back to the top