Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server ErrorRSS

19 replies

Last post Jun 05, 2019 06:50 AM by Jalpa Panchal

  • Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    May 31, 2019 03:17 AM|DEV_Beginner|LINK

    Hi Everyone 

    I have issue with PyRFC connection to SAP by host on IIS 7

    before I use PyRFC my application work fine and after I import PyRFC and Connect to Bapi Server IIS will show detail as below 

    HTTP Error 500.0 - Internal Server Error
    c:\python27\python27.exe - The FastCGI process exited unexpectedly

    Detailed Error Information:
    Module FastCgiModule
    Notification ExecuteRequestHandler
    Handler safetystock
    Error Code 0xffffffff
    Requested URL http://safety.svi.co.th:80/api_test/
    Physical Path D:\safetystock\api_test\
    Logon Method Anonymous
    Logon User Anonymous
    Request Tracing Directory C:\inetpub\logs\FailedReqLogFiles

    and this is my code:

    from pyrfc import Connection
    conn = Connection(user='sapconnect', passwd='mypassword', ashost='myhost', sysnr='00', client='100')

    When compiler run to line Connection() IIS will show error 500 but I try to run localhost on server application work fine.

    I already added full permission to root project folder and root python folder but it not work.

    I has been stuck in this problem for 3 days. Help me please

    python 2.7 64 bit

    django 1.11.16

    pyrfc 1.9.96

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    May 31, 2019 04:53 AM|lextm|LINK

    If PyRFC crashed Python processes, you should report to SAP, not here,

    https://github.com/SAP/PyRFC/issues

    Lex Li
    Affordable IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    May 31, 2019 05:03 AM|DEV_Beginner|LINK

    I think not PyRFC crashed because when I run in localhost it work fine. but run on IIS it crashed may be IIS can't find module Pyrfc 

    then I want to know how to add to pyrfc package to IIS (RFC SDK install at C:\nwrfcsdk )

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 06:19 AM|Jalpa Panchal|LINK

    Hi,

    Could you tell us where is RFC SDK was installed? and which account is used by the application pool?

    Regards,

    Jalpa.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 06:54 AM|DEV_Beginner|LINK

    Hi Jalpa

    I install RFC SDK at C:\nwrfcsdk and already add C:\nwrfcsdk\lib in system environment but when I run application on IIS , the system displays DLL load failed: The specified module could not be found  so I tried to move the file sapnwrfc.dll to C:\Python27\Lib\site-packages\pyrfc and system shows  error the same message as above (HTTP Error 500.0 - Internal Server Error)

    I guess IIS can't connect to package from C:\nwrfcsdk\lib but I already add full permission to that folder ( IUSER ) 

    I have no idea

    Thank you for reply

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 07:31 AM|Jalpa Panchal|LINK

    Could you share C:\nwrfcsdk\lib folder permission and iis application pool snapshot?

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 07:41 AM|DEV_Beginner|LINK

    Please see snapshot at

    folder permission -> https://ibb.co/fxNTKjc 

    application Pool in IIS -> https://ibb.co/tmdXpP6 

    I don't know how to add image to this forums

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 08:08 AM|Jalpa Panchal|LINK

    You could use this link https://imgur.com/upload to post the image in this forum. 

    You could also refer below post solution to resolve the issue.

    https://stackoverflow.com/questions/51825708/python-pyrfc-1-9-5-importerror-while-calling-from-iis-hosted-net-core-api

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 08:19 AM|DEV_Beginner|LINK

    Thank you for suggestion to upload image

    from stack overflow I've read that post, but I can't understand how to do it. I tried to add full permission all related folder but not work

    If you understand that post, please explain to me how to make it thoroughly. 

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 08:32 AM|Jalpa Panchal|LINK

    Select the application pool and then select iis application pool advance setting.

    In advance setting check application pool identity:

    Try to use Process Monitor to monitor w3wp.exe IIS worker process and python.exe after calling the API.

    dependency walker to track the dependent dll.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 08:59 AM|DEV_Beginner|LINK

    OK I've check application pool identity in advance setting

    and use procmon to monitor w3wp.exe and python.exe process 

    look like system find sapnwrfc.dll from all related folder but not find in C:\nwrfcsdk\lib folder

    https://imgur.com/UlmQiwB

    How to add this folder to system finder ?

    (and again I've upload image at imgur.com and can't input embed code to this site cry)

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 09:11 AM|Jalpa Panchal|LINK

    Check that dll is available in that folder or not and what is the error message shown at your application?could you share that detail error message snapshot?

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 03, 2019 09:45 AM|DEV_Beginner|LINK

    Now I have moved the sapnwrfc.dll  file to C:\Python27\Lib\site-packages\pyrfc\sapnwrfc.dll and system found it 

    Then I look at procmon again and find path C:\Python27\Lib\site-packages\pyrfc\sapnwrfc.dll.

    Procmon show FILE LOCKED WITH ONLY READERS at Results column

    https://imgur.com/H5ZBv4L 

    and result on web browser display error internal 500 when I call pyrfc connect function then I will look at permission on C:\Python27\Lib\site-packages\pyrfc\sapnwrfc.dll it have full permission 

    (sapnwrfc.dll permission )

    https://imgur.com/xo0gcoX

    (Web browser display)

    https://imgur.com/atzCrMj

    How to add read/write permission to sapnwrfc.dll from IIS ?

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 04, 2019 03:12 AM|Jalpa Panchal|LINK

    Hi,

    Check that you configured python in iis properly or not? your python folder and site folder has iis_iusrs, iusr and application pool full access permmision. which authentication are you using to access the site? 

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 04, 2019 05:43 AM|DEV_Beginner|LINK

    Hi

    I've checked python configuration in FastCGI Setting it work fine but I'm not sure if it's correct or not.

    https://imgur.com/pW6ELvy 

    and I have granted access IUSER and IIS_IUSER for python folder , site folder with full permission and I don't know how to grant access for application pool 

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 04, 2019 07:55 AM|Jalpa Panchal|LINK

    You could give application pool permission to the folder by:

    IIS AppPool\<myappoolname>

    Please provides application pool identity setting as suggested in this step:

    https://forums.iis.net/post/2149169.aspx

    Also, run FRT in iis :

    https://docs.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis#enable-failed-request-tracing

    When you enable, you capture status code from 200-500 so all the request will be logged. Then you can try accessing the site and check what is wrong by checking FREB traces.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 04, 2019 08:36 AM|DEV_Beginner|LINK

    I gave application pool permission from IIS to site folder and python folder

    Application Pool -> https://imgur.com/pxkDJOp 

    Folder Permission -> https://imgur.com/aW4t3YV 

    and track error log follow your suggestion and I receive error as below (What part of the information do I have to see?)

    https://drive.google.com/file/d/14bT5BS2ymH3Khxi_bmCPqbVEjy4MB7Mw/view?usp=sharing 

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 04, 2019 09:01 AM|Jalpa Panchal|LINK

    If possible could you please upload log file on one drive and share a link?

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 04, 2019 09:13 AM|DEV_Beginner|LINK

  • Re: Python(django) + PyRFC Connection() - HTTP Error 500.0 - Internal Server Error

    Jun 05, 2019 06:50 AM|Jalpa Panchal|LINK

    please check python log and share with us.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.