502 response when uploading large files to asp4 site - c#

Our site is able to handle files up to what seems 100mb.
When I upload a 100mb file, I receive the 502 bad gateway error after about 2 minutes and 20 seconds
When I upload a 200mb file, I receive the 502 bad gateway error after about 4 minutes
The above are only happening when <compilation debug="false".../>
When I set the <compilation debug="true".../> it succeeds
In my web.config I've got settings for both maxRequestLength and maxAllowedContentLength set to over a gig. I've also tried the executionTimeout setting, and it seems to have no effect.
I'm curious though in both the ~2 minute and ~4 minute requests that result in an error response... I can see that the server is actually doing the work with the file being uploaded. It's taking it, and putting it on a file share successfully and it's also going through and entering a row in our DB to track it... but it responds with a 502.
Running locally or running with <compilation debug="true".../> succeeds, if that helps at all.

Related

file upload fails with "Maximum request length exceeded."

I have a service that keeps failing with the above error. There are numerous posts and article's about the default size for file being 4mb and to increase the size via the web.config file. In my case the file size is 3.2mb so wouldn't expect to get this error. If I Increase the limit via the maxRequestLength attribute and the maxAllowedContentLength then this error is overcome. However, I'm trying to understand why I mighty be getting this error in the first place given that the filesize is below the 4mb limit. The file is an xml file and I'm posting to my service via postman.

ASP.NET throwing 404 for large file and 400 for extremely large files

Currently writing an API that accepts files using multipart/form-data. Below are my settings in Web.config. IIS is set to 1.0737GB limit and .NET is set to a 1.0485GB limit.
<httpRuntime requestValidationMode="2.0" maxRequestLength="1048576" executionTimeout="1000000" targetFramework="4.7.1" />
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
When I upload a file around 1.5-2GB in size I get a 404 back as described in the Microsoft documentation linked below. This is my expected response from the server. But, when I upload a much larger file, around 2.5GB+, I get a 400 Bad Request instead. I have been looking around for documentation to describe why this would happen and why I would not expect to always see a 404 instead, but have found nothing stating a 400 could be returned. The only difference between the requests is the files attached, nothing else is changed. To make the larger file size I also just zipped two of the original file that throws the 404 together. As additional details, the endpoint is covered in Unit and Integration tests that verify normal use case functionality. The endpoint works when manually tested with files below the IIS/.NET set limits. This behavior has also been seen when manually tested with a C# library project as well as Postman. Any help is greatly appreciated, thanks in advance!
https://learn.microsoft.com/en-us/iis/configuration/system.webserver/security/requestfiltering/
Clarification on my use case:
A clarification is that I'm not trying to increase the size limit of my requests, I just need to make sure anything over the size limit returns the same error. The documentation that will be publicly available needs to state the return value in case of error and currently it can be either a 404 or a 400 and I can't explain explicitly why in the documentation yet.
Thanks to help from all of the commenters, the following link provided by Brian Clink answered the question. https://sitecore.stackexchange.com/questions/11788/sitecore-media-file-upload-above-2gb-throws-bad-request-400
IIS forces the max size to be 2GB. So, for all requests less than 2GB that are larger than your custom IIS settings a 404.13 is returned. For all requests over 2GB a 404 is returned.

.NET WebService Timeout Exception

I am getting the following exception when calling a web service operation in my .NET application:
System.Net.WebException: The operation has timed out at
System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest
request) at
System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest
request) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters) at
org.wvi.hrmgmt.HRManagementServiceserviceagent.LoadReducedTemplate(LoadReducedTemplateRequest
LoadReducedTemplateRequest) at
org.wvi.mgmt.hr._ServiceClient.UploadReducedTemplate()
Basically, a user uploads a file into the web server and the binary contents of this file is being passed as one of the input parameters when calling a web service operation. The size of the file is 1,397 KB and if I choose to process this file, I am getting the exception. Whereas, processing a file with a relatively smaller size, supposed 127 KB, gives a successful response.
I have done the below steps in order to solve the dillema:
Setting the web service timeout to infinite. -> Not getting an exception and any response
Adding Response.Close() -> Not getting any response
Editing the web.config in the IIS server and adding the following lines: -> Still getting the exception
<system.web>
<customErrors mode="Off"/>
<httpRuntime executionTimeout="600" maxRequestLength="16384"/>
<sessionState timeout="540"/>
</system.web>
However, to no avail, I'm still getting the above exception. I am using a Javascript plugin called AjaxUpload from GitHub and I can't figure out whether they have file upload size limit. Besides, I have checked the file if it is being uploaded on the server and it does, therefore, the issue may not be because of that plugin.
Another issue is that I am getting the same exception when uploading the file after a period of time the web page has been opened. I surmise that this has something to do with session timeout so I added an additional line in my web.config file specifying the maximum timeout. Please advise me if I'm on the right track.
Are there additional settings I need to apply in my IIS server to make the operation successful? Otherwise, are there anything I am missing? If you have experienced this before, kindly inform me what to do.
Thank you so much,
Ralph
This might be due to lot of proxy opened before. So I suggest you to delete Service.Reference.Config along with web service reference and add the service reference again and see whether it solves your problem.
Adding on to the previous answer, you may try setting up the execution time out on the proxy class , Refer this discussion
And you service call is performing a long running task you may prefer to have a lengthy time out for any webservice call by setting the timeout in proxy class as said before.

Error 101 (net::ERR_CONNECTION_RESET): The connection was reset

I have develop a small asp.net MVC3 application in that i have upload a video files into Application server path.When i upload 2MB video file it is uploded .But when itry to upload 50mb file it is showing error like .
This webpage is not available
The webpage at http://localhost:1318/Campaign/Advertises might be temporarily down or it
may have moved permanently to a new web address.
Here are some suggestions:
Reload this web page later.
Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.
I have set the execution time and maxrequested length in web.config file.
<httpRuntime maxRequestLength="20480" executionTimeout="12000"/>
How can i solve this please help me..
<httpRuntime maxRequestLength="51200" executionTimeout="0"/>
Here
executionTimeout="0" takes unlimited time
maxRequestLength="51200" for 1mb=1024 so for 50mb=51200
Just to make the answer more complete for the next guy:
httpRuntime goes in <system.web>
executionTimeout value of 0 only works for some versions of IIS

The request timed out before the page could be retrieved. asp.net web application long server processing

i have a web application which which proccesses some request on some data that client selects, when the client selects more than 20 objects and clicks on proceed the client recieves this error, because the server takes a long time to process, however if the records are less and hence a timely response is recieved, no such error comes can someone help me on this?
i have increased the sessiontimeout as well as set the
Try adjusting the executionTimeout in your web.config...this only applies if debug is set to false however.
<httpRuntime
executionTimeout="some number"
/>
If this alone does not solve your issue, check out this blog post which goes into a bit more depth on how to structure your timeouts. Note the IIS reference towards the bottom...

Categories