Can we please have a notification scheme enabled for Undertow Jira?
by Darran Lofthouse
Can we please have a notification scheme enabling for the Undertow Jira
project so that we can receive e-mail notifications.
I would suggest just use the same one as is used for Remoting JMX, it
should be sufficient to have the notifications go to the general mailing
list and interested individuals.
Regards,
Darran Lofthouse.
10 years, 3 months
Caching Proxy / Proxy Extensions
by Ronny Karallus
Hi Undertow Team,
I just took a quick glimpse into Undertow, to be honest, as I was just
evaluating it for a project. I planed to use it as a standalone reverse
proxy including caching and SSI as an alternative to apache.
However, as far as I saw this is not yet a feature set available in
Undertow. Anyway, I am not worried to get my hands dirty and add a bit of
code myself, so I looked a bit closer onto the proxy example and the
underlying classes.
As far as I saw it should be possible to add a CacheHandler in front of the
ProxyHandler that just uses the proxy handler in case of a miss. However, I
did not find a good way to hook into the Proxy Handler (it's also final :(
) to extend its functionality to store the response in the cache.
Is there any way to do this? I'd love to have a hook on each processor that
enables the developer to add response processors. There I could add the
cache storage and also the SSI processing. Is something like this planed or
already available and just overlooked by me?
Appreciate your time
Best Regards
10 years, 7 months
Embedded undertow with servlet deployment and dispatch to worker threads
by Dragan Jotanovic
Hi,
I did some testing with servlet deployment on undertow and it seems that
servlet requests are always executed on IO thread instead of dispatched to
worker threads.
Basically I used modified servlet example from undertow github (I just
added Thread.sleep(5000) to servlet). When I send request simultaneously
from two browser tabs, first request is retrieved after 5 seconds as
expected, but the second after 10 seconds, which means that IO thread was
blocked until first request was completed.
Is there some configuration parameter in DeploymentInfo which forces
request to be dispatched to worker threads, or is there some other way to
prevent IO thread from blocking?
Bellow is the example source:
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import io.undertow.Handlers;
import io.undertow.Undertow;
import io.undertow.server.HttpHandler;
import io.undertow.server.handlers.PathHandler;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.DeploymentManager;
import java.io.IOException;
import java.io.PrintWriter;
import static io.undertow.servlet.Servlets.defaultContainer;
import static io.undertow.servlet.Servlets.deployment;
import static io.undertow.servlet.Servlets.servlet;
public class TestServer {
public static class TestServlet extends HttpServlet {
@Override
public void init(final ServletConfig config) throws
ServletException {
super.init(config);
}
@Override
protected void doGet(final HttpServletRequest req, final
HttpServletResponse resp) throws ServletException, IOException {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
PrintWriter writer = resp.getWriter();
writer.write("Done!");
writer.close();
}
@Override
protected void doPost(final HttpServletRequest req, final
HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
}
}
public static void main(String[] args) {
try {
String context = "/";
DeploymentInfo servletBuilder = deployment()
.setClassLoader(TestServer.class.getClassLoader())
.setContextPath(context)
.setDeploymentName("test.war")
.addServlets(
servlet("TestServlet",
TestServer.TestServlet.class)
.addMapping("/*"));
DeploymentManager manager =
defaultContainer().addDeployment(servletBuilder);
manager.deploy();
HttpHandler servletHandler = manager.start();
PathHandler path = Handlers.path(Handlers.redirect(context))
.addPrefixPath(context, servletHandler);
Undertow server = Undertow.builder()
.addHttpListener(8181, "0.0.0.0")
.setHandler(path)
.build();
server.start();
} catch (ServletException e) {
throw new RuntimeException(e);
}
}
}
10 years, 7 months
Wrong JSESSIONID cookie
by Derrick Childers
I think I've found a bug in undertow and I have patch. I thought I'd
explain. We have multiple War's serving a site. One war covers the root
context '/' and a variety of sub paths/contexts. A couple of other war's
server specific sub contexts, such as /selfserve. If you open a browser
and go to / and look at the browser cookies you will see JSESSIONID with
path=/. Then go to /selfserve and look at the cookies. You now have two
JSESSIONID cookies. One for path=/ and one for path=/selfserve. As far as
I know this is all normal and correct. From here when my app tries to use
the session it fails in various ways. What I found was that if I deleted
the JSESSIONID cookie that was associated with path=/ then everything
worked. After digging around in the code I found where the cookies are
being added to a HashMap by the name. It looks like the last cookie loaded
wins, which means the correct cookie is loaded first then overridden by the
wrong one.
I have a patch in git and can send a pull request.
--
Derrick Childers
10 years, 7 months
REST routing
by Bill O'Neil
I was curious what the best practices would be for url routing with many
endpoints.
For example
POST /user/
GET /user/{userId}
GET /document/{documentId} ContentType=appliction/json (only respond when
json is requested)
What would be the best option for this? I was able to achieve most of what
i wanted using the PredicatesHandler class. Is this a good choice?
This would build a List of PredicatedHandlers as well as the fall through
handler which I would use as a 404. I got an example working using the
text predicate format
method[GET] and path-template[value=\"/user/{userId}\"]
Is this a good approach or are there better recommendations?
Thanks,
Bill
10 years, 7 months
How to configure wss with undertow?
by 张林
Hi,
In the client side, I want to use "wss" to communicate with the server,
when I change the "ws" to "wss", it reported a error:
*java.lang.IllegalArgumentException: XNIO000100: 'https' URL scheme chosen
but no SSL provider given*
So I try to provide a ssl provider XnioSsl, but I found the
io.undertow.websockets.client.WebSocketClient not support.
in the code ,it invokes the method:
HttpUpgrade.performUpgrade(worker, null, newUri, headers, new
ChannelListener(handshake, newUri, bufferPool, ioFuture);
*NOT*
HttpUpgradeState(final XnioWorker worker,* final XnioSsl ssl*, final
InetSocketAddress bindAddress, final URI uri, final Map<String, String>
headers, final ChannelListener<? super T> openListener, final
ChannelListener<? super BoundChannel> bindListener, final OptionMap
optionMap, final HandshakeChecker handshakeChecker)
I think it doesn't support wss yet for undertow now? is it right? or could
you tell me how to do this? Thanks.
Sincerely yours,
Lynn
10 years, 7 months
Can't get customed header and attributes in the websocket handshakeheader.
by 张林
Hi,
We registed a web socket handler in the server, waiting for the clients to
connect. According to the usiness, we need to identify (or mark) a client
when it do handshake with the server, so I tried to set some customed
headers in the handshakeheader, just like:
WebSocketConnectionManager manager = new WebSocketConnectionManager(
webSocketClient, webSocketHandler,
"ws://localhost:8080/websocket/myHandler");
manager.setAutoStartup(true);
*manager.getHeaders().add("myHeader", "1234567");*
return manager;
I supposed to retrieve it from the WebSocketSession in the serverside, but
I can't get it. it is ok in the jetty server 9.
The server we used: wildfly 8.0.3 Release
The client dependencies:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-websockets-jsr</artifactId>
<version>1.0.3.Final</version>
</dependency>
This issue blocked me for some days, could you please help to figure out
what's the matter, and it is really appreciate if you can give some advice
to achieve that. Thank you very much!
Sincerely yours,
Lynn
10 years, 7 months
java.io.IOException: Broken pip
by Mike Hostetler
I'm using a WildFly 8.0.1 nightly and can easily recreate this error:
14:01:30,134 ERROR [io.undertow.request] (default task-18) Blocking request
failed HttpServerExchange{ GET /ottrservices/recentpatients}:
java.lang.RuntimeException: java.io.IOException: Broken pipe
at
io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:527)
at
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:287)
at
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
at
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
at
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:168)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:727)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[rt.jar:1.7.0_51]
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[rt.jar:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) [rt.jar:1.7.0_51]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
[rt.jar:1.7.0_51]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) [rt.jar:1.7.0_51]
at sun.nio.ch.IOUtil.write(IOUtil.java:51) [rt.jar:1.7.0_51]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)
[rt.jar:1.7.0_51]
at org.xnio.nio.NioSocketConduit.write(NioSocketConduit.java:150)
[xnio-nio-3.2.1.Final.jar:3.2.1.Final]
at
io.undertow.server.protocol.http.HttpResponseConduit.write(HttpResponseConduit.java:529)
at
io.undertow.conduits.ChunkedStreamSinkConduit.flush(ChunkedStreamSinkConduit.java:251)
at
org.xnio.conduits.ConduitStreamSinkChannel.flush(ConduitStreamSinkChannel.java:162)
[xnio-api-3.2.1.Final.jar:3.2.1.Final]
at
io.undertow.channels.DetachableStreamSinkChannel.flush(DetachableStreamSinkChannel.java:100)
at org.xnio.channels.Channels.flushBlocking(Channels.java:63)
[xnio-api-3.2.1.Final.jar:3.2.1.Final]
at
io.undertow.servlet.spec.ServletOutputStreamImpl.close(ServletOutputStreamImpl.java:623)
at
io.undertow.servlet.spec.HttpServletResponseImpl.closeStreamAndWriter(HttpServletResponseImpl.java:451)
at
io.undertow.servlet.spec.HttpServletResponseImpl.responseDone(HttpServletResponseImpl.java:525)
... 9 more
For this particular screen, we do send a lot of data back and forth via
REST requests. Some of it can be large.
I have this setting in my http-listener:
<http-listener name="default" socket-binding="http"
max-buffered-request-size="10485760" max-header-size="7864320"
allow-equals-in-cookie-value="true"/>
yes I picked those large values just to see if they would work and they
haven't. I see from this page:
http://undertow.io/documentation/core/listeners.html
That there is a MAX_ENTITY_SIZE in Undertow but I can't seem to get Wildfly
to recognize it -- when I try max-entity-size="something" in the
http-listener tag, I get a validation error.
Any ideas?
--
Mike Hostetler
http://mike.hostetlerhome.com/
10 years, 7 months
HTTP Upgrade in Servlet 3.1 - how to use non-blocking input & output at the same time
by Przemyslaw Bielicki
Hi,
I posted my question on wildfly-dev (
http://lists.jboss.org/pipermail/wildfly-dev/2014-March/001986.html) but I
think this one is better, as the implementation is in undertow-servlet, not
in wildfly itself.
I would like to use non-blocking input and output at the same time. For the
simplicity let's implement EchoProtocol - check the attachments.
As you see, the writer is in a separate thread created by manually (which
is a bit smelly IMHO). Another point is that I do the write directly
without checking whether I can write without blocking. In fact, when I call
ServletOutputStream.isReady() I get the Undertow error: "UT010034: Stream
not in async mode"
Checking the source code you are not really sure if it's a correct
behaviour:
io.undertow.servlet.spec.UpgradeServletOutputStream
io.undertow.servlet.spec.ServletOutputStreamImpl
@Override
public boolean isReady() {
if (listener == null) {
* //TODO: is this the correct behaviour?*
throw UndertowServletMessages.MESSAGES.streamNotInAsyncMode();
}
Another point - more to non-blocking itself. How can
ServletOutputStream.write(byte b[]) be non-blocking at all? Let's imagine
that the socket is ready to write and I call write with a buffer of 1000
bytes but the receiver is ready only to receive 500 bytes at this point. My
call will be blocked, right?
Cheers,
Przemyslaw
10 years, 8 months