chocolatey-community / simple-server

The Chocolatey Simple Server - https://community.chocolatey.org/packages/chocolatey.server
Apache License 2.0
44 stars 17 forks source link

push error: (413) Request Entity Too Large. #59

Open teknowledgist opened 3 years ago

teknowledgist commented 3 years ago

I have Chocolatey Simple Server (2019, IIS10) running successfully with a few small packages, but I cannot get it to accept packages of any size. I have been able to push/import a 4.7MB .nupkg, but when I try a 6.7MB .nupkg (my next smallest) or larger, I get:

Failed to process request. 'Request Entity Too Large'. 
The remote server returned an error: (413) Request Entity Too Large..

Except for the API Key, I don't think I've changed anything in the web.config file (I wouldn't know what I was doing.) from when it was set up. Specifically, maxRequestLength:

<system.web>
    <compilation debug="false" targetFramework="4.6" />
    <!-- maxRequestLength is specified in Kb -->
    <httpRuntime targetFramework="4.6" executionTimeout="1200" maxRequestLength="2147482548" />

and the maxAllowedContentLength:

<requestFiltering>
        <!-- maxAllowedContentLength is specified in Bytes -->
        <requestLimits maxAllowedContentLength="2147482548" />
      </requestFiltering>

are as they came and appear to be sufficient. Where else can there be a problem causing this error? I'm an IIS noob, but I figured that between the instructions and the chocolatey.server install, it would be all ready for "normal" use without esoteric tweaking required. Given that, I can't be the only person to have this problem.

Help is appreciated.

ferventcoder commented 3 years ago

It's likely a misconfiguration and the web.config is being ignored. Change it to add something that breaks it.

And it works fine for most people. Probably something small being missed.

ferventcoder commented 3 years ago

Assuming you can push something, but once you try to push anything slightly bigger it falls down tells me you have ASP.NET hooked up properly in IIS with the right app pool set up. So trying to look at other areas

teknowledgist commented 3 years ago

Well, I've narrowed down the size limit. I am able to push packages with a nupkg of 4,766,523 bytes or less, but I get the error on a package that is 4,842,218 bytes or more. I haven't searched for anything between those values, but I also don't think it would matter much.

Otherwise, I have no answer so far. I am NOT a web master, so a lot of IIS is a mystery to me.

ferventcoder commented 3 years ago

No worries. I think that something is misconfigured somewhere. I can definitely submit packages bigger than 4MB to an instance of Chocolatey.Server with no issue.

It might be a good idea to revisit the instructions at https://chocolatey.org/docs/how-to-set-up-chocolatey-server#setup-manually. (maybe start over - copy the packages you do have off somewhere first).

The chocolatey packages folder will contain chocolatey.server, but the actual implementation is likely at c:\tools\chocolatey.server - make sure the web.config there is good.

teknowledgist commented 3 years ago

I think I found the solution... (from: https://forums.iis.net/t/1239202.aspx?413+Request+Entity+Too+Large)

  1. Launch “Internet Information Services (IIS) Manager”
  2. Select the site that you are hosting your web application under it.
  3. In the Management section, double click Configuration Editor
  4. In the Section dropdown select: system.webServer then serverRuntime
  5. Modify the uploadReadAheadSize section to be like 20MB (so, 20971520 -- the value there is in Bytes)
  6. Click Apply

The value on my system was 1048576. I have no idea why a 1MB setting like that would cause a failure around the 4.6MB range, but with that change I have now successfully pushed a ~23MB package.

Hope this helps someone. (Maybe it it should be added to the setup page?)

teknowledgist commented 3 years ago

Well, back to the drawing board. I am now getting the same error for a 158MB package. I increased the uploadReadAheadSize indicated above to 50MB without success. When I tried 100MB, I get an error that it is outside the bounds of a uint32 value.

Clearly, this isn't the solution, and somehow I got lucky previously.

teknowledgist commented 3 years ago

So, I screwed up because the error about the uint32 value was because I cut and pasted the number (in bytes) and I didn't remove the commas from the number.

Once I change the value to the byte equivalent of 160MB (without commas!), it works.

teknowledgist commented 3 years ago

More weirdness:

I created an embedded package that was 233MB. I dropped the .nupkg into the "packages" folder, and maybe a day later (not sure exactly), it was still sitting there and Choco server didn't ingest it.

It's not clear to me how often the server checks for these .nupkg files, so I thought I would just push it to the server. When I attempted that, I got the "(413) Request Entity Too Large" error. This has been the same problem as all along since this package is larger than the 160MB I set the uploadReadAheadSize to (as above). It was the end of the day on Friday, so I left it as is for the weekend and didn't change anything.

Today, I thought I'd again change that uploadReadAheadSize to accommodate my larger package. However, I noticed that the .nupkg file was no longer in the "packages" folder. Instead, there was a new sub-folder with the package name. At some point over the three days, Chocolatey had ingested the same package it had just told me was too big!

How do I make sense of what is going on here? I can accept that pushing has a size limit which internal ingestion does not (although it would be nice for that to be documented somewhere), but how long should I expect a .nupkg file to sit in the "Packages" folder before it gets ingested? Where is that time configured/adjusted?

Thanks.