0

What causes Unhandled exception in wfastcgi.py: Traceback (most recent call last) in python flask app +IIS...

I' m creating a web app with Python flask and IIS 10 web service on windows server 2022. I have problem in the wfastcgi log file that is configured in web.config. The content of the log:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\wfastcgi.py", line 774, in main
    record = read_fastcgi_record(fcgi_stream)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\wfastcgi.py", line 158, in read_fastcgi_record
    data = stream.read(8)     # read record
OSError: [Errno 22] Invalid argument
2023-05-27 13:56:42.139969: Running on_exit tasks
2023-05-27 13:56:42.141971: wfastcgi.py 3.0.0 closed
2023-05-27 13:56:45.739017: Unhandled exception in wfastcgi.py: Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\wfastcgi.py", line 774, in main
    record = read_fastcgi_record(fcgi_stream)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\wfastcgi.py", line 158, in read_fastcgi_record
    data = stream.read(8)     # read record
OSError: [Errno 22] Invalid argument
2023-05-27 13:56:45.743023: Unhandled exception in wfastcgi.py: Traceback (most recent call last)

every time when i am giving any data through form then it take data & save it to mongo db but at the times of processing data in backend its not processing ..

Whole web.config text is bellow:

<configuration>  
  <system.webServer>
    <handlers>
        <add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Users\Administrator\AppData\Local\Programs\Python\Python39\python.exe|C:\Users\Administrator\AppData\Local\Programs\Python\Python39\Lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
        <directoryBrowse enabled="true" />
  </system.webServer>
  <appSettings>
    <add key="WSGI_HANDLER" value="my_app.app" /> <!-- {name_of_file}.{name_of_flask_app}-->
    <add key="PYTHONPATH" value="C:\inetpub\wwwroot\flask-ins" />
      <add key="WSGI_LOG" value="C:\inetpub\wwwroot\flask-ins\app.log" />
  </appSettings>
    <system.web>
        <authentication mode="Forms" />
    </system.web>
</configuration>  

configuration: python 3.9 windows sever 2022 IIS - 10 wfascgi - 3.0.0

Any help will be really appreciated.

Thank you.

I tried updating the wfastcgi using pip also but same issue

Nayan
  • 9
  • 4
  • wfastcgi isn't maintained by Microsoft any more, so even a slightest change in IIS FastCGI can break it. Either you find a community patch for this (won't on PyPI), or you switch to other Python on IIS hosting option. – Lex Li May 29 '23 at 06:12
  • other python in the sense mean version. if the version I can't switch becoz of Dependencies issue. is there any other module in place wfastcgi in python flask IIS – Nayan May 29 '23 at 06:28
  • Please check [this similar case](https://stackoverflow.com/questions/70305734/what-causes-unhandled-exception-in-wfastcgi-py-traceback-most-recent-call-last), maybe it helpful for you. And have you checked related code based on the error message? – Xudong Peng May 29 '23 at 09:24
  • i tried django case but again same issue – Nayan May 30 '23 at 10:44

0 Answers0