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

Connot establish a connection: RFC_COMMUNICATION_FAILURE & Connection refused #343

Closed Yasine001 closed 10 months ago

Yasine001 commented 10 months ago

I am trying to make a connection to our bw system on hana using pyrfc, but I keep getting a communication error:

CommunicationError: 1 (rc=1): key=RFC_COMMUNICATION_FAILURE, message= LOCATION CPIC (TCP/IP) on local host with Unicode ERROR partner 'ip_address:port' not reached TIME Sun Nov 5 10:14:31 2023 RELEASE 753 COMPONENT NI (network interface) VERSION 40 RC -10 MODULE /bas/753_REL/src/base/ni/nixxi.cpp LINE 3458 DETAIL NiPConnect2: ip_address:port SYSTEM CALL connect ERRNO 111 ERRNO TEXT Connection refused COUNTER 20 [MSG: class=, type=, number=, v1-4:=;;;]

I started off by using the following arguments:


from pyrfc import Connection

conn = Connection(ashost='hostname',client='000', user=me, passwd=secret, lang='DE')

I get the error above.. then I extracted the possible parameters from our eclipse-based query designer, where a connection is already established:

SystemId_client_user_de {client=310, language=DE, user=me, systemConfiguration={Name=SystemId [BW/4HANA Abnahme] | Host=hostname | Origin=MS_SEL_GROUPS_SNC| SystemConfigurationLinkedToSapLogon=true | SystemConfigurationFromFileBasedCache=false | Description=Description| SystemId=SystemId| Group=Group| Server=null | SystemNumber=null | MessageServerService=MessageServerService| MessageServer=hostname | PartnerName=p:CN=SAP... | Router=null | LoadBalancing=true | SNCType=SNC_HIGHEST_AVAILABLE | SNCEnabled=true | PreferredUser=null | PreferredClient=null | GatewayServer=null | SSOEnabled=true | GatewayServerService=null | PreferredLanguage=null}}

and I mapped them to Connection Class in the PyRFC module:


from pyrfc import Connection

conn = Connection(ashost='xxxxxxxxx', client='310',group=group, mshost='xxxxxxxxxx', msserv='0000', user=me, passwd=secret, lang='DE')

But it did not make any difference. I still get the same error. Can you help please on what could be needed to establish a connection.

bsrdjan commented 10 months ago

What kind of ABAP system you are trying to connect to? Is it ECC ot S4H and which release?

You can check with ABAP system admin or Basis consultant which RFC connection parameters shall be used: ashost, mshost, client ... It depends on ABAP system configuration.

RFC connection parameters are described in sapnwrfc.ini file, in SAP NW RFC SDK demo folder.

Yasine001 commented 10 months ago

Hello @bsrdjan, thank you so much for the response.

It is definitely S4H. I will check with my ABAP system admin about RFC connection parameters.

But in principle all parameters described in sapnwrfc.ini can be passed to a connection in PyRFC? The keyword are the same but they are lower case as described in the documentation?:

https://sap.github.io/PyRFC/pyrfc.html#pyrfc.Connection

bsrdjan commented 10 months ago

Hello @Yasine001,

yes, sapnwrfc.ini describes all RFC connection parameters and provided few examples when and how to use them.

The keywords are case insensitive and recommended way is to use local sapnwrfc.ini file, so that sensitive connection parameters are not exposed in Python source.

With local sapnwrfc.ini like this one for example, Python client connection can be opened like:

client = Connection(dest="rfctest")
client = Connection({"dest": "BIN_HS0011"})
# etc.
Yasine001 commented 10 months ago

hallo @bsrdjan, thank you so much,

I was able to get to the system now, using only

MSHOST
MSSERV

instead of

ASHOST
SYSNR

as described in sapnwrfc.ini. because the system seems to be behind a load balancer.

Thanks fo the support!