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
Occurrence of write timeout on client\server side
by Вячеслав А
Hello.
I can't understand how "Write Timeout" works and when this timeout happens.
I am using undertow as part of WildFly appserver.
I can set Read Timeout as a small value (for example, 1 sec).
And then all request will be rejected and browser request will be marked as
closed (i can see this status in browser dev tools).
But nothing happens when i set a small value for Write Timeout. All my
request complete successfully.
I am using also "clumsy" for slow speed emulation.
I can see, that connection should be closed at break point:
io.undertow.conduits.WriteTimeoutStreamSinkConduit.handleWriteTimeout
I see, that "IoUtils.safeClose(this.connection)" called, but nothing
happens in browser.
Could you explain, please, how can i see the result of write timeout on
server or client (prefered) side.
7 years, 3 months
Using undertow client with proxy servers
by Kim Rasmussen
Hi,
I have a usecase where I have a reverse proxy that uses a customized
ProxyHandler - for some hosts, I need to proxy the requests onwards via a
proxy server - e.g. a bluecoat proxy.
So something like this:
Browser --> Undertow reverse proxy --> Bluecoat Proxy --> Web server
So, I need to use the undertow client with a (non-reverse) proxy server.
I am guessing that with a ClientRequest, for non-ssl requests I should just
be able to change the path from /mypath to http://my.server.name/mypath
before sending it to the proxy server instead of to the destination host
directly.
But what would be the ideal way of handling this when I need SSL so I need
to wrap the requests inside a "CONNECT my.server.name:443 HTTP/1.1" block
before starting the SSL negotiation ? Any pointers ?
Would creating a specific ClientProvider be a sensible way ?
--
Med venlig hilsen / Best regards
*Kim Rasmussen*
Partner, IT Architect
*Asseco Denmark A/S*
Kronprinsessegade 54
DK-1306 Copenhagen K
Mobile: +45 26 16 40 23
Ph.: +45 33 36 46 60
Fax: +45 33 36 46 61
7 years, 4 months
Best practice for receiving/writing HTTP body by chunks
by Eldad Rudich
Hi,
I'm implementing custom HTTP reverse proxy using Undertow.
My server is listening to requests and when a new request arrives, It wraps
the request in a proprietary protocol and redirect to another component in
my system.
That component takes the request data, unpack it, send it to the actual web
server, get's the response and send the response back to my Undertow server
in the same proprietary protocol.
The server unpacks the response and writes it back to the user's browser.
All works very well for "small" requests/response but for request/response
that has body data that exceed some predefined amount I would like to split
the request/response to chunks ( my own chunking mechanism, not related to
HTTP chunking) to better handle such scenarios and not hold the entire data
in the server's memory.
In order to do that I need access to the request/response body bytes,
I came by this thread:
http://lists.jboss.org/pipermail/undertow-dev/2015-January/001080.html and
tried to implement both proposed solutions
When I used the async interface:
HttpServerExchange.getResponseSender().send(bodyByteBuffer, myIoCallback)
Sometimes my callback just not called ( nor the onComplete or the
onException callbacks) for unknown reasons.
So I tried the blocking interface instead ( from dispatched handler ):
HttpServerExchange.startBlocking()
HttpServerExchange.getResponseSender().send(bodyByteBuffer)
That works but I read somewhere in this mailing list that the async
interface is more efficient.
The same behavior occurred when trying to receive the request body using:
HttpServerExchange.getRequestReceiver()
and also solved using the blocking interface.
Am I missing something? what are the best practices for reading/writing
partial request/response body?
Best,
Eldad.
7 years, 4 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, 4 months