Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect SAP system from python using PYRFC, SAPGUI login works fine #212

Closed
rushikeshk-k opened this issue Nov 26, 2020 · 13 comments
Labels

Comments

@rushikeshk-k
Copy link

rushikeshk-k commented Nov 26, 2020

Hi @bsrdjan
I am working on to create connection of Python with SAP ECC using PYRFC. When I try it from SAPGUI my connection works fine, but when tried it from Python code it does not work on my PC. But again it works from my other team members pc from python

So I checked all the configuration on my pc, are identical to other members pc. So I am clueless now,

  • Server details are changed to - XYZ.com
root@4a4ed54a8426:/app/models# python Check_pyrfc.py
Traceback (most recent call last):
  File "Check_pyrfc.py", line 4, in <module>
    conn = Connection(user='BOTID', passwd='XXXXX', ashost='XYZ.com', sysnr='50', client='100')
  File "src/pyrfc/_pyrfc.pyx", line 173, in pyrfc.pyrfc.Connection.__init__
  File "src/pyrfc/_pyrfc.pyx", line 221, in pyrfc.pyrfc.Connection._open
  File "src/pyrfc/_pyrfc.pyx", line 251, in pyrfc.pyrfc.Connection._error
pyrfc._exception.CommunicationError: RFC_COMMUNICATION_FAILURE (rc=1): key=RFC_COMMUNICATION_FAILURE, message=
LOCATION    CPIC (TCP/IP) on local host 4a4ed54a8426 with Unicode
ERROR       partner 'XYZ.com:3350' not reached
TIME        Thu Nov 26 14:11:34 2020
RELEASE     753
COMPONENT   NI (network interface)
VERSION     40
RC          -10
MODULE      /bas/753_REL/src/base/ni/nibuf.cpp
LINE        4568
DETAIL      NiBufIConnect: connection pending after 60000ms
SYSTEM CALL connect
ERRNO       115
ERRNO TEXT  Operation now in progress
COUNTER     4
 [MSG: class=, type=, number=, v1-4:=;;;]

When checked with nslookup, I get proper IP of the server

C:\Program Files (x86)\SAP\FrontEnd\SAPgui>nslookup XYZ.com
Server:  XYZ.com
Address:  11.106.2.13 (ip changed)

Non-authoritative answer:
Name:    XYZ.com
Address:  192.30.33.16 (ip changed)

Need your urgent help to find out the exact reason and where to fix it. As per your comments in other issue I tried Niping, it also works fine. Please let me know if you need any more details.

Thank you in advance for your help

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 26, 2020

Perhaps the domain name resolution does not resolve the XYZ.com to ip addr. Did you try to replace the hostname with the host ip address in ashost connection parameter?

@rushikeshk-k
Copy link
Author

rushikeshk-k commented Nov 26, 2020

Thank you for your response.
I tried with both XYZ.com and with Ip directly in my python code as below. I works fine from SAPGUI, also works from my team members pc. But when I am trying to connect from my pc it does not work and I am getting same error,

from pyrfc import Connection

conn = Connection(user='BOTID', passwd='XXXXX', ashost='XYZ.com', sysnr='50', client='100')
#conn = Connection(user='BOTID', passwd='XXXXX, ashost='192.30.33.16', sysnr='50', client='100')

result = conn.call('STFC_CONNECTION', REQUTEXT=u'Hello SAP!')
print(result)
{u'ECHOTEXT': u'Hello SAP!',
 u'RESPTEXT': u'SAP R/3 Rel. 702   Sysid: ABC   Date: 20121001   Time: 134524   Logon_Data: 100/ME/E'}
Error:
 File "src/pyrfc/_pyrfc.pyx", line 173, in pyrfc.pyrfc.Connection.__init__
  File "src/pyrfc/_pyrfc.pyx", line 221, in pyrfc.pyrfc.Connection._open
  File "src/pyrfc/_pyrfc.pyx", line 251, in pyrfc.pyrfc.Connection._error
pyrfc._exception.CommunicationError: RFC_COMMUNICATION_FAILURE (rc=1): key=RFC_COMMUNICATION_FAILURE, message=
LOCATION    CPIC (TCP/IP) on local host 4a4ed54a8426 with Unicode
ERROR       partner 'XYZ.com:3350' not reached
TIME        Thu Nov 26 16:34:15 2020
RELEASE     753
COMPONENT   NI (network interface)
VERSION     40
RC          -10
MODULE      /bas/753_REL/src/base/ni/nibuf.cpp
LINE        4568
DETAIL      NiBufIConnect: connection pending after 60000ms
SYSTEM CALL connect
ERRNO       115
ERRNO TEXT  Operation now in progress
COUNTER     4
 [MSG: class=, type=, number=, v1-4:=;;;]

One thing I notices when I tried from SAPGUI it connect to "XYZ.com:sapdp50 (3250) and when I try it from Python code it connect to XYZ.com:3350.

Do I need to check on firewall setting or add this ip and port anywhere to give network access??

Thank you in advance for your kind help.. much needed

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 26, 2020

Looks like port for the load balancer is missing. Please check similar issues: SAP-archive/node-rfc#146 and #79, also the "Parameters for load balancing" example in sapnwrfc.ini file, in SAP NWRFC SDK demo folder.

You can try with

MSHOST=XYZ.com
MSSERV=3250

instead of:

ASHOST=XYZ.com
SYSNR=50

@rushikeshk-k
Copy link
Author

rushikeshk-k commented Nov 26, 2020

Thank you for your response!

after trying,
MSHOST=XYZ.com
MSSERV=3250

I got below error

--------------------------------
[Thr 20400] Fri Nov 27 01:30:43:185 2020
[Thr 20400] +--------+-------------------------------------+------------------+
[Thr 20400] | Offset | Data (14 bytes)
[Thr 20400] +--------+-------------------------------------+------------------+
[Thr 20400] | 000000 | 2a2a4450 544d4d53 472a2a00 00f8     | **DPTMMSG**...   |
[Thr 20400] +--------+-------------------------------------+------------------+
Traceback (most recent call last):
  File "Check_pyrfc.py", line 3, in <module>
    conn = Connection(user='BOTID', passwd='XXXX', mshost='XYZ.com', msserv ='3250', client='100')    
  File "src\pyrfc\_pyrfc.pyx", line 173, in pyrfc.pyrfc.Connection.__init__
  File "src\pyrfc\_pyrfc.pyx", line 221, in pyrfc.pyrfc.Connection._open
  File "src\pyrfc\_pyrfc.pyx", line 251, in pyrfc.pyrfc.Connection._error
pyrfc._exception.CommunicationError: RFC_COMMUNICATION_FAILURE (rc=1): key=RFC_COMMUNICATION_FAILURE, message=
ERROR       The message received isn't from a message server.
            Are you really connected to the message server?
            Please check your connection parameters.
            (XYZ.com / 3250)
TIME        Fri Nov 27 01:30:43 2020
RELEASE     753
COMPONENT   MS (message handling interface, multithreaded)
VERSION     4
RC          -29
MODULE      D:/depot/bas/753_REL/src/krn/ms/msxxi.c
LINE        382
COUNTER     1
 [MSG: class=, type=, number=, v1-4:=;;;]

I really appreciate your help on it.

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 27, 2020

Not sure what could be the problem. Could you please share the screenshot of system connection parameters, from SAP Logon client? Example:
SAPGUI

@rushikeshk-k
Copy link
Author

rushikeshk-k commented Nov 27, 2020

Hi bsrdjan

Now my connection is working from Python running on windows. but same code id I am running from Docker -Linux image it is giving same error. Do you have any idea about Docker, if any change needs to be made to make connection happen

ERROR       partner 'XYZ.com:3350' not reached
TIME        Thu Nov 26 16:34:15 2020
RELEASE     753
COMPONENT   NI (network interface)
VERSION     40
RC          -10
MODULE      /bas/753_REL/src/base/ni/nibuf.cpp
LINE        4568
DETAIL      NiBufIConnect: connection pending after 60000ms
SYSTEM CALL connect
ERRNO       115
ERRNO TEXT  Operation now in progress
COUNTER     4
 [MSG: class=, type=, number=, v1-4:=;;;]

Thanks a ton for your response and help

@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 30, 2020

The same connection parameters should work from docker as well, no special changes required for docker.

Did you try the IP instead of XYZ.com ?

@rushikeshk-k
Copy link
Author

bsrdjan, Thank you for your response.
I tried with IP as well, but still not working. But it works perfectly fine from Python on Windows.

@bsrdjan
Copy link
Contributor

bsrdjan commented Dec 2, 2020

It looks like a network error. Did you try the niping test from docker ?

You can also try with SAP/fundamental-tools docker images, regularly used in testing, like the python-39.Dockerfile for example.

@bsrdjan
Copy link
Contributor

bsrdjan commented Feb 11, 2021

@rushikeshk-k ,

if it works on Windows and not on other platforms, please check this answer and try with:

pip uninstall pynwrfc
PYRFC_BUILD_CYTHON=yes pip install pynwrfc --no-binary :all:

@bsrdjan
Copy link
Contributor

bsrdjan commented Apr 23, 2021

Please try also 2.4.0: pip install pyrfc (package name changed and upgrade to SDK PL8 first)

@bsrdjan bsrdjan closed this as completed Apr 23, 2021
@abdullahansari00
Copy link

I am trying to connect with SAP using this library. Do I need SAP installed on my system?

@bsrdjan
Copy link
Contributor

bsrdjan commented Oct 7, 2021

@abdullahansari00 no, all prerequisites are listed in README: https://github.com/SAP/PyRFC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants