Correctly shutting down a websocket handler
by Robin Anil
When a client disconnects, I see that onClose is not being fired. The only
way this seems to be firing if client sents a close frame.
Is there any way to detect disconnection and immediately close all the
opened resources.
Robin
Robin Anil | Software Engineer
1 year, 2 months
Undertow Http Server - Handling 2 Millions Requests Per Second Per Instance
by SenthilKumar K
Hello Undertow Dev Team ,
I have been working on the use case where i should create simple http
server to serve 1.5 Million Requests per Second per Instance ..
Here is the benchmark result of Undertow :
Running 1m test @ http://127.0.0.1:8009/
20 threads and 40 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 2.51ms 10.75ms 282.22ms 99.28%
Req/Sec 1.12k 316.65 1.96k 54.50%
Latency Distribution
50% 1.43ms
75% 2.38ms
90% 2.90ms
99% 10.45ms
1328133 requests in 1.00m, 167.19MB read
Requests/sec: *22127*.92
Transfer/sec: 2.79MB
This is less compared to other frameworks like Jetty and Netty .. But
originally Undertow is high performant http server ..
Hardware details:
Xeon CPU E3-1270 v5 machine with 4 cores ( Clock 100 MHz, Capacity 4 GHz) ,
Memory : 32 G , Available memory 31 G.
I would need Undertow experts to review the server code below and advice me
on tuning to achieve my goal( ~1.5 Million requests/sec ).
Server :
Undertow server = Undertow.builder()
.addHttpListener(8009, "localhost")
.setHandler(new Handler()).build();
server.start();
Handler.Java
final Pooled<ByteBuffer> pooledByteBuffer =
exchange.getConnection().getBufferPool().allocate();
final ByteBuffer byteBuffer = pooledByteBuffer.getResource();
byteBuffer.clear();
exchange.getRequestChannel().read(byteBuffer);
int pos = byteBuffer.position();
byteBuffer.rewind();
byte[] bytes = new byte[pos];
byteBuffer.get(bytes);
String requestBody = new String(bytes, Charset.forName("UTF-8") );
byteBuffer.clear();
pooledByteBuffer.free();
final PostToKafka post2Kafka = new PostToKafka();
try {
*post2Kafka.write2Kafka(requestBody); { This API can handle ~2 Millions
events per sec }*
} catch (Exception e) {
e.printStackTrace();
}
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("SUCCESS");
--Senthil
7 years, 4 months
Can't get remote_user with basic auth
by Brad Wood
Hello, I'm having troubles getting the remote_user cgi variable when using
basic authentication. The basic auth itself seems to work fine. The
browser challenges me, I enter a user/pass, and the page loads. However
request.getRemoteUser() is returning null.
Here is the bits that are setting up the basic auth handler:
https://github.com/cfmlprojects/runwar/blob/master/src/runwar/security/Se...
I've Googled quite a bit and I can't find any guides that indicate that
anything special needs set up for remote user to be available. I also
found the exchange attribute class for remote user in Undertow, but can't
find any docs or guides at all that indicate how it is to be used or if I
need to be doing anything with it in regards to basic auth.
Can someone provide a sanity check on what is missing for the remote user
to be available?
Using Undertow 1.4.11.Final
Thanks!
~Brad
*Developer Advocate*
*Ortus Solutions, Corp *
E-mail: brad(a)coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
7 years, 5 months
UT005085 connection was not closed cleanly, forcibly closing connection
by Christoph Sturm
hello undertow developers!
We see this exception
UT005085: Connection io.undertow.server.protocol.http.HttpServerConnection@7ba04d76 for exchange HttpServerExchange{ POST /pixel ….. response {Connection=[close], Content-Length=[0], Date=[Mon, 12 Jun 2017 16:31:06 GMT]}} was not closed cleanly, forcibly closing connection
in our log files, and looking at the undertow source that should never happen. is this something related to our code or is it just some strange behaviour from the client?
if it’s something that we cannot fix, maybe it can be logged by the io logger instead to so we can turn it off easily?
or is there a jboss-logging way to disable logging for a single error code?
thanks
chris
7 years, 5 months
Questions about Undertow's ByteBufferPool
by Violeta Georgieva
Hi,
I have few questions about Undertow's ByteBufferPool.
Are there any best practices how it should be used?
Also are the ByteBuffers always fixed in size?
Thanks,
Violeta
7 years, 5 months
how to disable io exception logging
by Sascha Sadat-Guscheh
hello undertow developers!
we are trying to disable logging of io exceptions like the comment in UndertowLogger.java suggests:
/**
* Logger used for IO exceptions. Generally these should be suppressed, because they are of little interest, and it is easy for an
* attacker to fill up the logs by intentionally causing IO exceptions.
*/
UndertowLogger REQUEST_IO_LOGGER = Logger.getMessageLogger(UndertowLogger.class, UndertowLogger.class.getPackage().getName() + ".request.io");
so we disable io.undertow.request.io
but it seems that there are still io exceptions logged as io.undertow.request, i see log entries like this:
io.undertow.request 2017-06-08 23:44:14,898 UT005003: IOException reading from channel java.io.IOException: UT000128: Remote peer closed connection before all data could be read
at io.undertow.conduits.FixedLengthStreamSourceConduit.exitRead(FixedLengthStreamSourceConduit.java:338)
at io.undertow.conduits.FixedLengthStreamSourceConduit.read(FixedLengthStreamSourceConduit.java:255)
at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
at io.undertow.channels.DetachableStreamSourceChannel.read(DetachableStreamSourceChannel.java:209)
at io.undertow.server.HttpServerExchange$ReadDispatchChannel.read(HttpServerExchange.java:2287)
at io.undertow.server.handlers.form.FormEncodedDataDefinition$FormEncodedDataParser.doParse(FormEncodedDataDefinition.java:134)
at io.undertow.server.handlers.form.FormEncodedDataDefinition$FormEncodedDataParser.handleEvent(FormEncodedDataDefinition.java:115
to me it seems that the handler for form encoded post data uses the wrong logger for its io exceptions.
best, sascha
7 years, 5 months