There is nothing preventing you accepting a connection and then immediately sending an error response assuming a request is coming, and half closing the connection. You can then give it a Connection class that just consumes any characters received up to a low limit or short timeout.
On Fri, 21 May 2021, 05:02 Josh Spiegel, <joshlak...@gmail.com> wrote: > 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 > > > > _______________________________________________ > jetty-users mailing list > jetty-users@eclipse.org > To unsubscribe from this list, visit > https://www.eclipse.org/mailman/listinfo/jetty-users >
_______________________________________________ jetty-users mailing list jetty-users@eclipse.org To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users