SAP / PyRFC

Asynchronous, non-blocking SAP NW RFC SDK bindings for Python
http://sap.github.io/PyRFC
Apache License 2.0
500 stars 132 forks source link

How to solve key=RFC_COMMUNICATION_FAILURE issue?! #364

Open IT-HONGREAT opened 5 months ago

IT-HONGREAT commented 5 months ago

I met key=RFC_COMMUNICATION_FAILURE error, and study documents&git issues. But i didn't solve this error. I ask for your help.

Environment

I installed sapnwrfc pkg. and export envs.

envs

DYLD_LIBRARY_PATH=/usr/local/sap/nwrfcsdk/lib
SAPNWRFC_HOME=/usr/local/sap/nwrfcsdk
SAPNWRFC_INI_FILE=/Users/myname/PycharmProjects/myproject/src/app/sap_rfc/sapnwrfc.ini

This is my sapnwrfc.ini file.

DEST=TEST
ASHOST=some_ip
CLIENT=100
LANG=KO
SYSNR=20
USER=something
PASSWD=something
RFC_TRACE=3

This is my connection code from some examples.

import os

from pyrfc import Connection

print(os.getenv("SAPNWRFC_INI_FILE"))
client = Connection(dest="TEST")
print(client)

result = client.call("STFC_CONNECTION", REQUTEXT="Hello SAP!")
print(result)

And comes this error.

pyrfc._exception.CommunicationError: 1 (rc=1): key=RFC_COMMUNICATION_FAILURE, message=
LOCATION    CPIC (TCP/IP) on local host with Unicode
ERROR       partner 'some_ip:some_port' not reached
TIME        Fri Mar 15 15:33:27 2024
RELEASE     753
COMPONENT   NI (network interface)
VERSION     40
RC          -10
MODULE      /bas/753_REL/src/base/ni/nibuf.cpp
LINE        4593
DETAIL      NiBufIConnect: connection pending after 60000ms
SYSTEM CALL connect
ERRNO       36
ERRNO TEXT  Operation now in progress
COUNTER     2
 [MSG: class=, type=, number=, v1-4:=;;;]

Thanks

bsrdjan commented 5 months ago

Setting DYLD_LIBRARY_PATH has no effect for PyRFC on MacOS because of System Integrity Runtime Protections. No need to use it. SAPNWRFC_HOME also has no effect on runtime.

The error message is about network issue, which means the RFC SDK libraries are loaded and PyRFC could not reach the ABAP system. The cause are usually wrong connection parameters or network connectivity issues.

Could you please check connection parameters and sapnwrfc.ini file location?

sapnwrfc.ini default location is current working directory. The full path to sapnwrfc.ini (including file name) can be configured using RFC_INI env variable (not SAPNWRFC_INI_FILE). Alternatively, sapnwrfc.ini directory (without file name) can be set using PyRFC function set_ini_file_directory. More info are in this comment https://github.com/SAP/PyRFC/issues/275#issuecomment-1104912776

If the issue still persist, you set the global RFC trace level and remove it from destination connection parameters, like this

DEFAULT
RFC_TRACE=3 # 'global' trace level

Then run the test and send the trace. If the trace contains sensitive info, you can create SAP customer incident for BC-MID-RFC-SDK component and post the trace there, with reference to this issue.