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
How to modify the response with ProxyHandler
by Andrea Di Cesare
Hi undertow-dev <undertow-dev(a)lists.jboss.org>,
I'm using ProxyHandler with LoadBalancingProxyClient and in some cases I
need to modify the response content received from the backed before sending
it to the client.
HttpServerExchange.addResponseCommitListener() allows to modify the
response and using it I'm able, for instance, to add a response header but
not modifyng the content from the backend since it is not available.
Is it possible? What are the suggested ways of implementing this behavior?
Thanks,
Andrea Di Cesare
5 years, 8 months
Async/Rx approach in HttpHandlers
by Girish Sharma
Hi,
I have been trying to find some solid examples for using
Observables/Callbacks/Futures to delegate long running tasks (which return
the response to be sent back) over to separate threads. The idea is that
the handler method simply spawns an async task and whenever that async
tasks completes, we send back the response without making the handler
method/worker threads wait for the async task to finish.
Any pointers/examples would be appreciated.
--
Girish Sharma
5 years, 8 months
Undertow - Read/Write timeout
by Prabhash Rathore
Hello,
I am writing a Web Server using undertow. I am trying to set up read and write timeouts using below code but this does not work. I went through undertow documentation but I didn't see any other way to set up timeout other that what I am trying?
Undertow.Builder undertowBuilder = Undertow.builder();
undertowBuilder.addHttpListener(80, "localhost");
undertowBuilder.setServerOption(Options.WRITE_TIMEOUT, 10);
undertowBuilder.setServerOption(Options.READ_TIMEOUT, 20);
I also tried to set up using setSocketOptions and setWorkerOptions but that dididn't work either? As a side nots, I am not clear on the difference of these three options: ServerOptions, SocketOptions and WorkerOptions. Any help or pointers will be appreciated.
Thanks!Prabhash Rathore
5 years, 9 months
ProxyHandler returns 503 under load
by Jocke Eriksson
Hello,
We are trying to build an API gateway using undertow as a servlet extension, this has been working great until we started our performance tests.
Our setup is two gateways balancing traffic towards 10+ servers and we are using JBoss EAP 7.0 We have observed that some of our requests fail with 503 response. When we get a 503 response from a request, we have also observed that it never reaches the proxy target.
I made a small test on my machine to see if I could get the same error, to my surprise this was very easy. First I tried with the following code.
public class ApiGatewayServletExtension implements ServletExtension {
@Override
public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) {
LOG.info("Deploying {}...", MethodHandles.lookup().lookupClass().getSimpleName());
deploymentInfo.addInitialHandlerChainWrapper(handler -> {
try {
LoadBalancingProxyClient loadBalancer = new LoadBalancingProxyClient()
.addHost(new URI("http://localhost:8282"))
.setConnectionsPerThread(20);
return new ProxyHandler(loadBalancer, 30000, handler);
} catch (URISyntaxException ex) {
throw new IllegalStateException(ex);
}
});
}
}
I used JMeter with 20 threads making a simple rest GET request and after 30 seconds or so the test stopped with a 503 response.
Then I created a small java application using undertow 2.0.17.Final like this.
public static void main(final String[] args) {
try {
LoadBalancingProxyClient loadBalancer = new LoadBalancingProxyClient()
.addHost(new URI("http://localhost:8282"))
.setConnectionsPerThread(20);
ProxyHandler proxyHandler = new ProxyHandler(loadBalancer, 30000, ResponseCodeHandler.HANDLE_404);
Undertow server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(proxyHandler).build();
server.start();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
Getting the same result. I have also tried just loading the home page of one of our servers and still the same result.
Any help would be very much appreciated. I have not created a bug because I'm pretty sure we are just missing something here.
Regards Joakim Eriksson.
5 years, 9 months