Does Undertow support JMX for remote management? Is there any documentation
that explains how JMX can be set up for Undertow? I would assume it's
similar to the "sibling" projects WildFly and JBoss AS (use remote+http
protocol and jboss-client.jar but I haven't made it to work, so I am
wondering what I am missing).
*Think**near* | Software Engineer
Is it possible to get the full content of a response body before it's sent? I'm trying to sign the response and add this signature in a header. There was a similar question on this list a couple of weeks ago, but that one was about signing the incoming request. My current approach is, in HttpHandler.handleRequest():
- Create a javax.crypto.Signature object
- Use HttpServerExchange. addResponseWrapper() to add a StreamSinkConduit that updates the Signature object as write() is called
- Use HttpServerExchange.addResponseCommitListener() to add a callback that calls Signature.sign() when the response is ready to be sent
Good in theory, but I'm finding that the sign happens before the updates - looks like the Conduit is only active as the response is being sent. Is there something else I should wrap to get the bytes as they're being added to the response? Even better would be if I could read them directly from the ResponseCommitListener.beforeCommit() callback. I can see the number of bytes that have been written, but not the actual data.
Note: I'm using Undertow 1.2.x, as we're on WildFly 9.
The information contained in this electronic mail transmission
may be privileged and confidential, and therefore, protected
from disclosure. If you have received this communication in
error, please notify us immediately by replying to this
message and deleting it from your computer without copying
or disclosing it.
I will soon go live with a project of mine which uses Undertow.
I was wondering if you could give me some advice on tweaking Undertow for
the production use.
The only things I found are:
Number of configurable things on the documentation and also when I was
reading the code drove me crazy :)
My use case is:
* Undertow only used as a websocket endpoint of an MMO game; no servlet or
* Binary data only (Protobufs, specifically)
* 300-400 concurrent connections per server
* High frequency of transfer, again per server (23 KB/s transfer out per
connection; 1 KB/s transfer in per connection)
* Limited server specs (1 core CPU, 1GB RAM)
I know I cannot of course ask you the exact configuration. What I am
looking for is some help at pointing at the right direction.
My Blog: http://blog.aliok.com.tr
I'm not sure if this is the right channel to go for help, but there seems
to be no separate user list, so I'll take a shot here.
I need to create a HttpHandler that fully reads the request body and stores
it into a buffer or byte before ending the exchange. For this, I'm trying
to digest what Undertow's RequestBufferingHandler does.
It seems that I have to take care of the scenario where the handler is
called before the entire request body is available on the stream by doing
- read from the stream
- check whether I've hit the end of the stream when as many bytes as
possible have been read
- if not, register a listener on the stream and continue handling the
request from there
- if so, handle the request from the handler directly
- finally close the stream
Can someone assert that the above is correct?
Also, are there general pointers to what I'd like to achieve (read the
request body into a buffer)?
Many thanks, cheers,
I have been (not so frequently) visiting the github repository to find that
new versions of undertow have been released. But when I visit undertow.io
site, there is no information on what's new in the latest version.
Thus, this post.
Is there any changelog or what's new blog for Undertow 1.2, 1.3, 1.4 and/or
B.Tech(H), Civil Engineering,
Indian Institute of Technology, Kharagpur
I'm trying to write some unit tests with an embedded undertow server. I’d
like to have the server find an open port. This makes the tests more robust
in many ways. For example, tests can be run in parallel and if a socket is
held in CLOSE_WAIT or something from a previous test the next test will
still run and succeed. With most servers I’ve used you can pass 0 for the
port and the server will find an open port. This doesn’t seem to be the
case with Undertow. Even if that would work, I don't see a method like
getPort() on the Undertow object so I don't know how I'd discover the port
to which it bound. Is this possible??
CTO, Analytic Spot
44 West Broadway #222
Eugene, OR 97401
analyticspot.com • 425-296-6556
I packed all buzzwords into the subject and I promise to talk about real issues from now on.
This is about issue https://issues.jboss.org/browse/UNDERTOW-626, the background, possible solutions and workarounds. But first I’d like to thank Steward for his quick response to the issue and also to my problem with HotSpot 1.8.0_71. Build problem solved!
I live in a country that has 9 states. In the area I work, they share a datacenter. Some applications are organised centrally (one database for all states), some are organised locally (each state has its own database and its own application server). We have a rather big application that is organised locally. Since there are quite a few users and we want to have good availability, each state has at least two JBoss servers (EAP6.4 right now). So we have about 20 servers in production. The problem now is, that they don’t live an isolated life, but sometimes they have to talk to each other. And not only with each other but also with a few other applications, some of them organised locally, some centrally. Usually they communicate synchronously with web services. Usually web services are configured point-to-point. This creates quite some configuration challenge. And I’m not talking about micro services here.
To ease the problem, a kind of hub and spoke architecture was introduced. Apache httpd with mod_jk is put in front of some applications. This eases configuration to some degree. But it has its downsides. When you kill the hub, all lights go out. Been there, done that, not fun! Also when you add some servers or applications, you have to configure the central mod_jk. The later problem can be solved with mod_cluster. I love mod_cluster! You don’t have to configure it. Just add servers, deploy or undeploy applications on JBoss, no configuration on the central hub necessary.
Architects recommend a bus-architecture to overcome the downsides of a central hub. A service bus should have a decentral organisation similar to a hardware bus. Applications connect to the bus and should be able to exchange messages without further configuration. However, when I looked at products called “Enterprise Service Bus”, I had difficulties to see the bus, most look like hub and spoke architectures.
But then the Undertow team announced the support for mod_cluster in Undertow, which got me really excited. Now it could be possible to create a service bus to connect WildFly servers. You just configure mod_cluster within WildFly and you send web service requests to your own server (localhost) instead of the real destination (https://developer.jboss.org/thread/249311). Because mod_cluster knows about the location of all other servers with the same multicast-address (the bus-adress), it sends the request to the final destination. A real service bus, almost configuration free and comes out of the box with WildFly. Is it only me or do others think as well that this could be a real burner?
The Proof of Concept
Yes, it does work! We created a setup with two nodes, which shows that the idea can work: https://github.com/AdrianFarmadin/modcluster-invmhttp-example
Unfortunately we ran into a problem, which I was not able to solve properly until now.
The problem is described in https://issues.jboss.org/browse/UNDERTOW-626. When you have local context and modcluster filter, modcluster sends requests first to other servers and creates a loop.
The Solutions or Workarounds
Excluding certain contexts
In UNDERTOW-626 Steward suggests:
<filter-ref name="modcluster" predicate="not path-prefix(/myapp)”/>
Unfortunately i couldn’t test it until now, but I will soon. It could work for our special case, since we have only one application on one server and only a few contexts. Something like that would have to work:
<filter-ref name="modcluster" predicate="not path-prefix(/myapp) and not path-prefix(/myappws) and not path-prefix(/myappadmin)”/>
Additionally we don’t deploy or undeploy applications at runtime, so we don’t have to configure this dynamically.
The solution will be problematic, if you e.g. undeploy one out of several applications on WildFly. Then you would have to reconfigure the predicate and remove some parts of the "and not path-prefix(/…)” This makes it rather difficult.
In modcluster filter: Don’t handle context, if its from the local server
In https://github.com/undertow-io/undertow/pull/356/files we tried to change the mod cluster filter such that it doesn’t forward a request if it the context exists on the local server.
We used this for our proof of concept for which it worked.
The problem is, that is uses conventions from WildFly to answer the question “What is my local jvmroute”. The system-property “jboss.node.name” is the default in WildFly, but thats not necessarily true otherwise. But we couldn’t find how to access the configuration property instance-id within undertow.
Fix it in WildFly
In https://github.com/undertow-io/undertow/pull/356 Steward pointed out that the problem should be solved in WildFly. Could you point us in a direction where we could go? We are willing to invest some time into this issue, but we don’t have enough inside knowledge from Undertow or WildFly jet.
Put modcluster at the end of the handler chain
Right now modcluster is invoked before the deployed applications are invoked. Maybe one could do it the other way round and invoke modcluster only if the deployed applications return “not found”? I just don’t know enough about Undertow to decide whether this is feasible or just a stupid idea.
Any remarks, ideas, and help are welcome.
I am trying to create what I call a URL mapping handler that maps path and query variables from the http request to java method parameters via annotations. It is a bit like what Spring or JAX-RS does. The intent is to reduce a bunch of the boilerplate associated with validation of incoming requests, but nothing more than that.
One of the stumbling blocks I have come upon is threading model used in calling handlers. I am trying to understand if
1) there is only meant to be a single handler shared by multiple threads such that it must handle multithreading2) the handler instances are somehow cloned.3) one handler is being assigned to a single thread at a time.
Without me diving into the code to figure this out, can someone please clarify this? To me this would be a good addition to the handler guide.