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
1 week, 4 days
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
2 years, 5 months
Re: [undertow-dev] Handlers routing
by Fernando Cruz
Stuart:
Many thanks for the changes. Where I can get the version 1.4.23.Final?
Best Regards
________________________________
From: Stuart Douglas <sdouglas(a)redhat.com>
Sent: Monday, January 22, 2018 9:25 PM
To: Fernando Cruz
Subject: Re: Handlers routing
This looks like a bug, I have filed https://issues.jboss.org/browse/UNDERTOW-1272.
I am a bit worried that it may cause minor compat problems, but if so they can be fixed by removing the trailing / from the template.
Stuart
On Tue, Jan 23, 2018 at 4:40 AM, Fernando Cruz <boggard(a)hotmail.com<mailto:boggard@hotmail.com>> wrote:
Hi,
I have an issue with the path template for the built in handler "Handlers.routing", when execute this implementation:
public class UndertowOnePathVariableApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(UndertowOnePathVariableApplication.class);
public static void main(final String[] args) {
Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(
Handlers.routing()
.get("/api/v1/orders/", (exchange) -> {
LOGGER.info("The path template defined is '/api/v1/orders/'");
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.setStatusCode(StatusCodes.OK)
.getResponseSender().send("All Orders");
})
.get("/api/v1/orders/{orderId}", (exchange) -> {
LOGGER.info("The path template defined is '/api/v1/orders/{orderId}'");
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.setStatusCode(StatusCodes.OK)
.getResponseSender().send(
"Order '" + exchange.getQueryParameters().get("orderId").getLast() + "'");
}))
.build()
.start();
}
}
I get this responses:
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Connection: keep-alive
< Content-Length: 0
< Date: Sun, 21 Jan 2018 02:01:53 GMT
<
* Connection #0 to host localhost left intact
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/ HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 10
< Date: Sun, 21 Jan 2018 02:02:45 GMT
<
* Connection #0 to host localhost left intact
All Orders
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/12345'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/12345 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 13
< Date: Sun, 21 Jan 2018 02:03:56 GMT
<
* Connection #0 to host localhost left intact
Order '12345'
That I thing is correct because I just define two paths: '.../orders/' and '.../orders/{orderId}'. And the path '.../orders', that is not defined, respond 404. But when use this implementation:
public class UndertowTwoPathVariablesApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(UndertowTwoPathVariablesApplication.class);
public static void main(final String[] args) {
Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(
Handlers.routing()
.get("/api/v1/orders/{orderId}/items/", (exchange) -> {
LOGGER.info("The path template defined is '/api/v1/orders/{orderId}/items/'");
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.setStatusCode(StatusCodes.OK)
.getResponseSender().send(
"Order '" + exchange.getQueryParameters().get("orderId").getLast() + "'");
})
.get("/api/v1/orders/{orderId}/items/{itemId}", (exchange) -> {
LOGGER.info("The path template defined is '/api/v1/orders/{orderId}/items/{itemId}'");
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.setStatusCode(StatusCodes.OK)
.getResponseSender().send(
"Order '" + exchange.getQueryParameters().get("orderId").getLast() +
"' Item '" + exchange.getQueryParameters().get("itemId").getLast() + "'");
}))
.build()
.start();
}
}
I get this responses:
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/12345/items'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/12345/items HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 13
< Date: Sun, 21 Jan 2018 02:08:45 GMT
<
* Connection #0 to host localhost left intact
Order '12345'
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/12345/items/'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/12345/items/ HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 21
< Date: Sun, 21 Jan 2018 02:09:11 GMT
<
* Connection #0 to host localhost left intact
Order '12345' Item ''
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/12345/items/09876'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/12345/items/09876 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 26
< Date: Sun, 21 Jan 2018 02:09:30 GMT
<
* Connection #0 to host localhost left intact
Order '12345' Item '09876'
That I thing is incorrect because there are just two paths again: '.../orders/{orderId}/items/' and '.../orders/{orderId}/items/{itemId}' but the curl with the exact URI use the second path template. Is this an issue or what I am doing wrong?
Best Regards
Fernando Cruz
8 years, 1 month
Handlers routing
by Fernando Cruz
Hi,
I have an issue with the path template for the built in handler "Handlers.routing", when execute this implementation:
public class UndertowOnePathVariableApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(UndertowOnePathVariableApplication.class);
public static void main(final String[] args) {
Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(
Handlers.routing()
.get("/api/v1/orders/", (exchange) -> {
LOGGER.info("The path template defined is '/api/v1/orders/'");
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.setStatusCode(StatusCodes.OK)
.getResponseSender().send("All Orders");
})
.get("/api/v1/orders/{orderId}", (exchange) -> {
LOGGER.info("The path template defined is '/api/v1/orders/{orderId}'");
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.setStatusCode(StatusCodes.OK)
.getResponseSender().send(
"Order '" + exchange.getQueryParameters().get("orderId").getLast() + "'");
}))
.build()
.start();
}
}
I get this responses:
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Connection: keep-alive
< Content-Length: 0
< Date: Sun, 21 Jan 2018 02:01:53 GMT
<
* Connection #0 to host localhost left intact
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/ HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 10
< Date: Sun, 21 Jan 2018 02:02:45 GMT
<
* Connection #0 to host localhost left intact
All Orders
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/12345'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/12345 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 13
< Date: Sun, 21 Jan 2018 02:03:56 GMT
<
* Connection #0 to host localhost left intact
Order '12345'
That I thing is correct because I just define two paths: '.../orders/' and '.../orders/{orderId}'. And the path '.../orders', that is not defined, respond 404. But when use this implementation:
public class UndertowTwoPathVariablesApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(UndertowTwoPathVariablesApplication.class);
public static void main(final String[] args) {
Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(
Handlers.routing()
.get("/api/v1/orders/{orderId}/items/", (exchange) -> {
LOGGER.info("The path template defined is '/api/v1/orders/{orderId}/items/'");
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.setStatusCode(StatusCodes.OK)
.getResponseSender().send(
"Order '" + exchange.getQueryParameters().get("orderId").getLast() + "'");
})
.get("/api/v1/orders/{orderId}/items/{itemId}", (exchange) -> {
LOGGER.info("The path template defined is '/api/v1/orders/{orderId}/items/{itemId}'");
LOGGER.info("The request URI '{}' and URL '{}'", exchange.getRequestURI(), exchange.getRequestURL());
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.setStatusCode(StatusCodes.OK)
.getResponseSender().send(
"Order '" + exchange.getQueryParameters().get("orderId").getLast() +
"' Item '" + exchange.getQueryParameters().get("itemId").getLast() + "'");
}))
.build()
.start();
}
}
I get this responses:
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/12345/items'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/12345/items HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 13
< Date: Sun, 21 Jan 2018 02:08:45 GMT
<
* Connection #0 to host localhost left intact
Order '12345'
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/12345/items/'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/12345/items/ HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 21
< Date: Sun, 21 Jan 2018 02:09:11 GMT
<
* Connection #0 to host localhost left intact
Order '12345' Item ''
boggard@xiuhcoatl:~$ curl -v 'http://localhost:8080/api/v1/orders/12345/items/09876'
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /api/v1/orders/12345/items/09876 HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: text/plain
< Content-Length: 26
< Date: Sun, 21 Jan 2018 02:09:30 GMT
<
* Connection #0 to host localhost left intact
Order '12345' Item '09876'
That I thing is incorrect because there are just two paths again: '.../orders/{orderId}/items/' and '.../orders/{orderId}/items/{itemId}' but the curl with the exact URI use the second path template. Is this an issue or what I am doing wrong?
Best Regards
Fernando Cruz
8 years, 1 month
Dynamically add / remove servlets within a context in Undertow
by Martin Petzold
Dear Undertow community,
my environment is OSGi. I would like to run an embedded web server and
add / remove servlets on-the-fly. In Jetty this seem to be possible for
servlets contexts but not servlets within a context. It also seems to be
possible with some extra work with Jetty. I was wondering if Undertow
might be a bit more convenient for this case.
Is this possible with undertow and how could I do it?
Thanks and regards,
Martin
8 years, 1 month