cjac
cjac

Reputation: 113

Django on IIS: Debugging IIS Error due to FastCGI request timeout on large file upload

I'm trying to host a Django web application on a windows 10 machine with IIS 10 with FastCGI. Whilst everything is running good so far, I'm running into problems with certain POST-requests while uploading larger files (~120MB), namely an HTTP 500 Error. I'm at a point where I don't know how to debug any further.

I resolved the Error "413.1 - Request Entity Too Large" by increasing the request limits. However, now I get an HTTP-error stating the following:

C:\Apps\Python3\python.exe - The FastCGI process exceeded configured request timeout

The timeout is set to 90 seconds, and I can tell that after the uploading of files completes, my browser is waiting about that time for a response from the server.

There are not that much operations to perform within the Django-view for responding to the request. If I run the django developement server on the same machine, the response is beeing send justs seconds after the files were uploaded. The duration, the IIS takes to send the HTTP 500 response, takes more than 1 minute longer.

I added some code to the Django-view in the post()-method to write something to a file whenever the method is called:

def post(self, request, *args, **kwargs):
    with open(os.path.join(settings.REPORT_DIR, "view_output.txt"), "w") as f:
        f.write("tbd.")
(...)

However, this action is never performed, although it works in other Django-Views. I therefore assume a problem with IIS processing the request.

I enabled FREB logging, but am a little lost with interpretation. The "Errors & Warnings" just state the LOG_FILE_MAX_SIZE_TRUNCATE event, probably due to the large request.

Since I'm new to IIS, how can I debug any further?

Thank you very much!

Upvotes: 5

Views: 1815

Answers (1)

Jalpa Panchal
Jalpa Panchal

Reputation: 12749

To resolve the issue you could follow the below steps:

The IIS default file upload size is 30mb(30000000 bytes) increase this value by using:

  • open IIS manager, select your site.

  • Double click request filtering feature from the middle pane.

enter image description here

  • From the Actions pane on the right-hand side of the screen click Edit Feature Settings... link.

enter image description here

  • In the Request Limits section, enter the appropriate Maximum allowed content length (Bytes) e.g.2147483648 which means 2GB and then click the OK button.

enter image description here

  • click ok and apply the setting then go back.

    increase the site connection time out:

  • Open Internet Information Services (IIS) Manager.

  • Expand the local computer node, expand Web Sites, right-click the appropriate Web site, point to Manage Web Site, click Advanced Settings.

  • In the Advanced Settings window, expand Connection Limits, change the value in the Connection time-out field, and then click OK.

enter image description here

Application Pool setting:

  • Open IIS.
  • On the left side, select"Application Pools"
  • On the right side, right-click this application pool and select Advanced Settings.
  • In the advanced settings, increase "Idle Time-out (minutes)".

enter image description here

CGI Time out:

  • in IIS, double-click the CGI icon and increase "Time-out".

enter image description here

Upvotes: 5

Related Questions