Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am getting 504 gatewaytimeout error on server after upload 3.92 MB files

but record get inserted into table successfully

i have 1 webserver and 1 appserver

on Webserver:

- i am reading excel file and convert it into datable and save excel
into another folder its hardly take 1 min 20 sec
- then i passed that datable to to appserver using following code

sProposal = Task.Run(async () =>
 {
   UploadDetails x = await webAPIClient.CallWebAPI<UploadDetails, DataTable>(dataTable, ConfigurationManager.AppSettings["Url"].ToString());
   return x;
                                    });
                                }


on Appserver
- i take datatable and pass into sqlbulkcopy and insert into table ,return with only success msg it hardly get few sec

Following is my web.config
<location path="upl">
   <system.web>
     <!--The default size is 4096 kilobytes (4 MB). MaxValue is 2147483647 KB (2 TB)-->
     <!-- 100 MB in kilobytes -->
     <httpRuntime executionTimout="3600" maxRequestLength="2147483647" />
   </system.web>
   <system.webServer>
     <security>
       <requestFiltering>          
         <!--The default size is 30000000 bytes (28.6 MB). MaxValue is 4294967295 bytes (4 GB)-->
         <!-- 100 MB in bytes -->
         <requestLimits maxAllowedContentLength="4294967295" />
       </requestFiltering>
     </security>
   </system.webServer>
 </location>


i also increase maxRequestLength,maxAllowedContentLength also but still it showing 504 gateway timeout on server

but record get inserted successfully (total 45,345 record)

What I have tried:

i also increase maxRequestLength,maxAllowedContentLength, and profile code which code take what time and all but still 504 error is coming
Posted
Updated 21-Jun-23 18:36pm
v3

The maximum request length has no bearing on a timeout error. If you try to upload a file that's too large, you'll get a 404 error, not a timeout error.

Quote:
I am reading excel file and convert it into datable and save excel into another folder its hardly take 1 min 20 sec
...
I take datatable and pass into sqlbulkcopy and insert into table ,return with only success msg it hardly get 1 min and few sec
So your total execution time is somewhere over 2 minutes 20 seconds - ie: more than 140 seconds.

The default execution timeout depends on your application:

.NET Framework:
WebForms and synchronous MVC actions: 110 seconds.
Asynchronous MVC actions: 45 seconds.

.NET Core:
120 seconds.

All of those numbers are way below the length of time you've told us your code takes to execute.

If you can't get your code to run faster, you need to increase the execution timeout limit.

.NET Framework
WebForms and synchronous MVC actions:
In web.config, set configuration/system.web/httpRuntime/@executionTimeout to the number of seconds required - eg: 300

Asynchronous MVC actions:
Add the AsyncTimeout attribute[^] to your action, and specify the number of milliseconds required - eg: [AsyncTimeout(300_000)]

.NET Core
In web.config, set configuration/system.webServer/aspNetCore/@requestTimeout to the required time - eg: 00:05:00.
 
Share this answer
 
Comments
Akshay malvankar 22-Jun-23 0:29am    
hi Richard i already giving excutionTimout="3600"
and not 404 error its 504 gateway time out error
This is the same question that you posted yesterday at 504 gateway timeout error while uploading file in ASP.NET[^]. Please do not repost. If you have additional information then please use the Improve question link in your original post, and add complete details of what is not working.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900