1

I need to increase the max-post-size of my undertow configuration, because I got the following exception

java.io.IOException: UT000020: Connection terminated as request was larger than 10485760 
at io.undertow.conduits.FixedLengthStreamSourceConduit.checkMaxSize(FixedLengthStreamSourceConduit.java:168) 

and I need post requests with larger payloads.

However, I know that I could adapt standalone.xml, but I was not able to figure successfully out, how I can do this by programming or at least in web.xml (I need to be able to put the change in the build artifact rather than in the server configuration).

Edit:
I use the post requests with jax-rs @Post methods. If it is possible to e.g. annotate a payload size per request, it would also be OK, since there are only few requests needing higher payload size enabled.

Can anybody point my to what I can do?
Thanks in advance!

badera
  • 1,495
  • 2
  • 24
  • 49
  • `I need to be able to put the change in the build artifact rather than in the server configuration)` - why is that? You can script this change using the jboss-cli tool. – Steve C Sep 07 '16 at 05:45
  • Because this is the preferred way to deal with portable applications hosted in the cloud. This is an important 'best practise'. – badera Sep 07 '16 at 06:58
  • I'd be interested to know where you heard this. How are you deploying your application? – Steve C Sep 07 '16 at 07:38
  • You might also consider using WildFly Swarm for this purpose. This bundles your application, the bits of WIldFly that you use and it's configuration into a single executable jar file. – Steve C Sep 07 '16 at 07:47
  • @Steve C: You go off topic. The question is clear and makes sence. I need a solution for this scenario, if there is one; nothing else. – badera Sep 07 '16 at 08:37
  • I don't think he's that off topic. You wanted a way to define the `max-post-size` via your application. WildFly Swarm can do this. – James R. Perkins Sep 07 '16 at 17:49
  • I cannot use Swarm because the infrastructure is given. – badera Sep 07 '16 at 18:08

2 Answers2

1

I don't think it's possible with an annotation. You'd have to change the max-post-size attribute on the listener. A change to the listener requires a reload which is why it's not possible from an annotation.

With CLI on the default http-listener the command would be:

/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=max-post-size, value=20971520)
James R. Perkins
  • 16,800
  • 44
  • 60
  • Is there no way to setup the listener of the servlet in the web.xml? What I have found is how to setup size of multipart bodies etc. but not max-post-size. – badera Sep 07 '16 at 18:10
  • Not that I know of since it's JAX-RS. If it was a servlet you can use the `javax.servlet.annotation.MultipartConfig` annotation. Maybe something like this would work though http://stackoverflow.com/a/20883976. – James R. Perkins Sep 07 '16 at 18:26
0

Open admin console click configuration click subsystem click on web/http- undertow click on http HTTP-server-> defual-server edit max-post-size

KP Singh
  • 49
  • 4
  • The question was how to do it by programming, not by setting up wildfly specific configuration. -1 – badera Sep 28 '17 at 07:19