Undertow proxy handler + RequestLimit handler issue
by paroczizs
Hi Undertow Dev,
we built a custom integration component based on Wildfly 11 with Undertow
1.4.18. The application contains a couple of custom and built in handlers.
We found the following:
There is a RequestLimit handler right at the beginning and finally the
proxy handler. When the backend getting to be slow and the load is
relatively high the RequestLimit handler does its job queues the request
then throws the request above the queue. When the proxy times out it starts
to consume the queue, in some cases the exception below occurs and we found
that in this case the counter in the RequestLimit handler is not reduced
and the it can stuck the way to the backend.
Are there any possibility to handle the exception in a custom handler?
Thank you in advance, Zsolt
2018-11-28 12:02:19,518 ERROR [io.undertow.proxy] (default I/O-2) UT005028:
Proxy request to /lwi/optinus/getentityanswersservice failed:
java.nio.channels.ClosedChannelException
at
io.undertow.client.http.HttpClientConnection$5.handleEvent(HttpClientConnection.java:194)
at
io.undertow.client.http.HttpClientConnection$5.handleEvent(HttpClientConnection.java:173)
at
org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at
org.xnio.StreamConnection.invokeCloseListener(StreamConnection.java:80)
at org.xnio.Connection.close(Connection.java:142)
at org.xnio.IoUtils.safeClose(IoUtils.java:152)
at io.undertow.util.ConnectionUtils$3.run(ConnectionUtils.java:102)
at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:612)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:479)
6 months, 2 weeks
Creating a websocket proxy with undertow
by Marc Boorshtein
Using the 1.4 series, I'm trying to handle upgrade and websockets. Looking
at a few examples and the code I think what I need to do is:
1. add the WebSocketServlet to the right path
2. implement WebSocketConnectionCallback that will call my remote ws://
server
Am I on the right track? I haven't found an example of doing this with
undertow but found something similar with jetty (
https://github.com/chipster/chipster-web-server/blob/master/src/main/java...)
but I havne't found the same thing for undertow so any pointers would be
appreciated.
Thanks
Marc Boorshtein
7 months, 2 weeks
Issue with Undertow Client and SSL
by Thomas Segismont
Hi,
Openshift Origin uses Hawkular Metrics to store node and container data. In
this scenario, Hawkular Metrics calls the Kubernetes master server over
HTTPS to validate the client identity. This is implemented with Undertow
Client, as part of a ServletExtension (inside Wildfly 10) [1]. Works fine
in development and testing.
Now the Openshit team sees errors in the logs [2][3]. I couldn't reproduce
yet. Errors come in pair, first the "UT005001: An exception occurred
processing the request: java.lang.IllegalStateException: XNIO000017: Buffer
was already freed", and just after "XNIO001007: A channel event listener
threw an exception: java.lang.NullPointerException".
Does that ring a bell? I haven't been able to find a starting point by
looking into the source the code.
Thanks
--
Thomas Segismont
JBoss ON Engineering Team
[1] https://git.io/vrNyP
[2] https://issues.jboss.org/browse/HWKMETRICS-408
[3] https://issues.jboss.org/secure/attachment/12405779/hawkular.log
8 months, 2 weeks
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
3 years, 1 month
Http session timeout
by Marcin T.
Hi,
We used in our code setMaxInactiveInterval() method (indirectly by using HttpSession) to dynamically switch on/off timeouts. It worked perfectly on Wildfly 19.0.0.Final (which contains undertow-core v2.0.30), but suddenly stopped working when app has been migrated to spring-boot v.2.3.2.RELEASE (with embedded undertow-core v2.1.3.Final). Unfortunately our code invokes setMaxInactiveInterval() method outside of http request/response lifecycle. My question is if it is a chance to bring back the old functionality (with bumpTimeout() into setMaxInactiveInterval() or we should implement our own http session timeout mechanism?
Thanks,
Marcin.
6 years, 1 month
[undertow-dev] How to add servlet listeners after initialization
by Brad Wood
Here is a ticket I entered recently for a JVM app server that is
implemented as a servlet. It's getting errors when deployed on undertow
because it incorrectly tries to add a servletContext listener after the
servlet has been initialized.
https://luceeserver.atlassian.net/browse/LDEV-3028
Now to be clear, I'm not saying there's any issue with Undertow. Undertow
appears to be following the spec. I mostly link to that ticket just since
it has a clarifying stack trace in it.
The app server in question (Lucee) is attempting to register a
servletContext listener to detect the *contextDestroyed()* event so it can
do its own internal cleanup. Since I'd like to help offer some suggestions
to the Lucee project on how to accomplish what they need while staying
within the servlet spec, can anyone help explain what the correct (and
generic) way would be to accomplish this?
The stack trace shows the servlet was trying to add a listener from inside
their own init() method, so if the servletcontext is already initialized by
that time, does that mean it's impossible for a servlet to add a listener
to the context? Is there another standard way for a servlet to detect when
the context is destroyed that I can suggest?
Thanks!
~Brad
*Developer Advocate*
*Ortus Solutions, Corp *
E-mail: brad(a)coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
6 years, 2 months
[undertow-dev] Undertow configure TCP Keep Alive Parameters
by Rohit Rajwani
Hi,
I am using Undertow as server for my Java application, I am trying to
set TCP Keep Alive options using setSocketOptions() method of
Undertow.Builder (please see the below code).
For testing I am sending 1 message and then keeping the connection
alive without sending anything on it so that TCP-KeepAlive can be
observed. But somehow these fields are not being set, since I'm not
able to see any keep-alive packets in tcpdump capture, for the set
parameters.
Does Undertow support setting of these parameters? If yes, Is this the
right way to configure TCP Keep Alive parameters in Undertow or am I
missing something?
---------------------------------------------------------
@Bean
public ServletWebServerFactory undertowFactory() {
UndertowServletWebServerFactory undertowFactory = new
UndertowServletWebServerFactory();
// listen to http and enable http2
undertowFactory.addBuilderCustomizers((Undertow.Builder builder) -> {
builder.setWorkerThreads(maxWorkerThreads);
builder.addHttpListener(httpPort, "0.0.0.0");
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, isHTTP2Enabled);
builder.setServerOption(UndertowOptions.IDLE_TIMEOUT, 3600000);
builder.setSocketOption(Options.KEEP_ALIVE, true);
builder.setSocketOption(Option.simple(StandardSocketOptions.class,
"SO_KEEPALIVE", Boolean.class), true);
builder.setSocketOption(Option.simple(ExtendedSocketOptions.class,
"TCP_KEEPINTERVAL", Integer.class), 10);
builder.setSocketOption(Option.simple(ExtendedSocketOptions.class,
"TCP_KEEPIDLE", Integer.class), 10);
builder.setSocketOption(Option.simple(ExtendedSocketOptions.class,
"TCP_KEEPCNT", Integer.class), 10);
});
logger.info("Undertow Max Worker Threads: " + maxWorkerThreads);
undertowFactory.addDeploymentInfoCustomizers(deploymentInfo -> {
deploymentInfo.addInitialHandlerChainWrapper(gracefulShutdown());
});
// redirect http to https
if (redirectHTTP == true) {
undertowFactory.addDeploymentInfoCustomizers(deploymentInfo -> {
deploymentInfo.addSecurityConstraint(new SecurityConstraint()
.addWebResourceCollection(new
WebResourceCollection().addUrlPattern("/*"))
.setTransportGuaranteeType(TransportGuaranteeType.CONFIDENTIAL)
.setEmptyRoleSemantic(SecurityInfo.EmptyRoleSemantic.PERMIT))
.setConfidentialPortManager(exchange -> httpsPort);
});
}
return undertowFactory;
}
---------------------------------------------------------
Thanks,
Rohit Rajwani
6 years, 2 months
[undertow-dev] Undertow TCP Keep Alive parameters
by Rohit Rajwani
I am using Undertow as server for my Java application, I am trying to set TCP Keep Alive options using
setSocketOptions() method of Undertow.Builder (please see the below code).
For testing I am sending 1 message and then keeping connection alive without sending anything on it so that TCP-KeepAlive can be observed.
But somehow these fields are not being set, since I'm not able to see any keep-alive packets in tcpdump capture, for the set parameters.
Does Undertow supports setting of these parameters?
If yes, Is this the right way to configure TCP Keep Alive parameters in Undertow or am I missing something?
@Bean
public ServletWebServerFactory undertowFactory() {
UndertowServletWebServerFactory undertowFactory = new UndertowServletWebServerFactory();
// listen to http and enable http2
undertowFactory.addBuilderCustomizers((Undertow.Builder builder) -> {
builder.setWorkerThreads(maxWorkerThreads);
builder.addHttpListener(httpPort, "0.0.0.0");
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, isHTTP2Enabled);
builder.setServerOption(UndertowOptions.IDLE_TIMEOUT, 3600000);
builder.setSocketOption(Options.KEEP_ALIVE, true);
builder.setSocketOption(Option.simple(StandardSocketOptions.class, "SO_KEEPALIVE", Boolean.class), true);
builder.setSocketOption(Option.simple(ExtendedSocketOptions.class, "TCP_KEEPINTERVAL", Integer.class), 10);
builder.setSocketOption(Option.simple(ExtendedSocketOptions.class, "TCP_KEEPIDLE", Integer.class), 10);
builder.setSocketOption(Option.simple(ExtendedSocketOptions.class, "TCP_KEEPCNT", Integer.class), 10);
});
logger.info("Undertow Max Worker Threads: " + maxWorkerThreads);
undertowFactory.addDeploymentInfoCustomizers(deploymentInfo -> {
deploymentInfo.addInitialHandlerChainWrapper(gracefulShutdown());
});
// redirect http to https
if (redirectHTTP == true) {
undertowFactory.addDeploymentInfoCustomizers(deploymentInfo -> {
deploymentInfo.addSecurityConstraint(new SecurityConstraint()
.addWebResourceCollection(new WebResourceCollection().addUrlPattern("/*"))
.setTransportGuaranteeType(TransportGuaranteeType.CONFIDENTIAL)
.setEmptyRoleSemantic(SecurityInfo.EmptyRoleSemantic.PERMIT))
.setConfidentialPortManager(exchange -> httpsPort);
});
}
return undertowFactory;
}
6 years, 2 months