10 Replies Latest reply on Jun 21, 2017 3:20 PM by clairton.rodrigo.heinzen

    Wildfly 9.0.2 increasing max-post-size

    ganeshment

      Hi,

      At present Wildfly is using integer range validator to validate max-post-size parameter.

      We have requirement to support uploading of file size greater than 2.4GB (this limitation is due to integer range validator).

      Changing the validator to LongRangeValidator is allowing us to upload files larger than 2.4GB.

      org.jboss.as.web.WebConnectorDefinition.java

      protected static final SimpleAttributeDefinition MAX_POST_SIZE =

                  new SimpleAttributeDefinitionBuilder(Constants.MAX_POST_SIZE, ModelType.LONG)

                          .setAllowNull(true)

                          .setValidator(new LongRangeValidator(0, Long.MAX_VALUE, true, true))

                          .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)

                          .setDefaultValue(new ModelNode(2097152))

                          .setAllowExpression(true)

                          .build();

       

      Do you see any issues with the above approach or is there any other approach to achieve the same?

      Regards,

      Ganesh

        • 1. Re: Wildfly 9.0.2 increasing max-post-size
          jaysensharma

          Hello Ganesh,

           

          Please use the following CLI command :

           

          /subsystem=undertow/server=default-server/http-listener=default/:write-attribute(name=max-post-size,value=25485760)
          

           

          Generated XML config in your WildFly profile:

           

                  <subsystem xmlns="urn:jboss:domain:undertow:3.0">
                      <buffer-cache name="default"/>
                      <server name="default-server">
                          <http-listener name="default" max-post-size="25485760" redirect-socket="https" socket-binding="http"/>  <!-- NOTICE max-post-size="25485760"  -->
                          <host name="default-host" alias="localhost">
                              <location name="/" handler="welcome-content"/>
                              <filter-ref name="server-header"/>
                              <filter-ref name="x-powered-by-header"/>
                          </host>
                      </server>
                      . 
                      . 
                  </subsystem>
          

           

           

          See: http://wildscribe.github.io/Wildfly/8.0.0.Final/subsystem/undertow/server/http-listener/index.html

          AttributeValue
          Default Value10485760
          TypeLONG
          Nillabletrue
          Expressions Allowedtrue

          Regards

          Jay SenSharma

          • 2. Re: Wildfly 9.0.2 increasing max-post-size
            ganeshment

            My question is at present it does not allow any value larger than integer max value (does not allow mean even though I set it in standalone.xml while starting the server it fails with integer range validation error).

            Our requirement is to configure a value larger than integer max so we have made the required changes to use Long range validator. It is working but want to make sure this is the right approach.

            • 3. Re: Wildfly 9.0.2 increasing max-post-size
              ganeshment

              As most of the documents specify max-post-size type as LONG

              but when looked at the code in org.jboss.as.web.WebConnectorDefinition.java, max-post-size type is INT

              • 4. Re: Wildfly 9.0.2 increasing max-post-size
                jaikiran

                Can you try this against the recently released 10.0.0 CR5 and see if it works there? If it doesn't, please post the configuration file you are using and also the complete exception stacktrace.

                • 5. Re: Wildfly 9.0.2 increasing max-post-size
                  ganeshment

                  I have looked into 10 CR5 code and it is also using Integer type and validator.

                  https://github.com/wildfly/wildfly/blob/10.0.0.CR5/legacy/web/src/main/java/org/jboss/as/web/WebConnectorDefinition.java

                  protected static final SimpleAttributeDefinition MAX_POST_SIZE =
                     new SimpleAttributeDefinitionBuilder(Constants.MAX_POST_SIZE, ModelType.INT)
                    .setAllowNull(true)
                    .setValidator(new IntRangeValidator(0, true))
                    .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES)
                    .setDefaultValue(new ModelNode(2097152))
                    .setAllowExpression(true)
                    .build();

                   

                  I will post stack trace on Monday

                  • 6. Re: Wildfly 9.0.2 increasing max-post-size
                    ctomc

                    well, the code in WebConnectorDefintion is used by legacy web subsystem and it is not shared by undertow subsystem.

                     

                    For undertow subsystem it is defined here:

                     

                    wildfly/ListenerResourceDefinition.java at master · wildfly/wildfly · GitHub

                    which uses undertow/UndertowOptions.java at master · undertow-io/undertow · GitHub as definition of the attribute.

                     

                    and as you can see it is long.

                    • 7. Re: Wildfly 9.0.2 increasing max-post-size
                      ganeshment

                      We were setting same value to max-header-size and max-post-size and were getting Integer validation error. Copy paste problem.

                      max-header-size is Int type and we don't have requirement to set it to large value.

                      After correction we are able to work with files greater than 2.14GB.

                      Iam marking this post as answered

                      • 8. Re: Wildfly 9.0.2 increasing max-post-size
                        a.bader

                        Is there any way to setup the max-pool-size (independent of integer / long -> I use only 100MB but not only 10MB) programmatically or in web.xml?

                        I should be able to build a .war file containing this setting rather than needing modifs in standalone.xml / using the CLI.

                        • 9. Re: Wildfly 9.0.2 increasing max-post-size
                          clairton.rodrigo.heinzen

                          Hello

                           

                          I Solved this.

                           

                          I create META-INF/services/io.undertow.servlet.ServletExtension and put "IncreasePostSizeServletExtension" for this implemations

                           

                          import javax.servlet.ServletContext;

                          import io.undertow.server.HandlerWrapper;

                          import io.undertow.server.HttpHandler;

                          import io.undertow.servlet.ServletExtension;

                          import io.undertow.servlet.api.DeploymentInfo;

                           

                          public class IncreasePostSizeServletExtension implements ServletExtension {

                            @Override

                            public void handleDeployment(final DeploymentInfo deployment, final ServletContext context) {

                                deployment.addInitialHandlerChainWrapper(new HandlerWrapper() {

                                    @Override

                                    public HttpHandler wrap(final HttpHandler handler) {

                                       return new IncreasePostSizeHandlerDecorator(handler);

                                    }

                                });

                            }

                          }

                           

                          public class IncreasePostSizeHandlerDecorator implements HttpHandler{

                                private final HttpHandler delegate;

                                public IncreasePostSizeHandlerDecorator(final HttpHandler delegate) {

                                    super();

                                    this.delegate = delegate;

                                }

                                @Override

                                public void handleRequest(final HttpServerExchange exchange) throws Exception {

                                   delegate.handleRequest(exchange);

                                    exchange.setMaxEntitySize(61644800l);

                                }

                          }

                          • 10. Re: Wildfly 9.0.2 increasing max-post-size
                            clairton.rodrigo.heinzen