Closed castelo-software closed 4 years ago
Using niping didn't reveal anything useful. However, it seems like the problem might be on Docker EE's support for linux containers being experimental. Outside of the container, or using windows containers on the same server, there are no issues with resolving the hostnames.
Even though I haven't found a solution for this exact problem, I am using the workaround of using a Windows container instead, so I am closing the issue.
Have the same problem, but I don't want to use a windows container.. do anybody know another workaround?
@NicolasHomolka, are you using the latest PyRFC and NWRFC SDK releases? Can you share the Dockerfile so that I can try to reproduce?
Dockerfile: ` FROM python:slim
ARG BASE_IMAGETAG="develop" ARG RELEASE_DIR="/app"
COPY ./sap /usr/local/sap RUN cd ~ && echo 'export SAPNWRFC_HOME=/usr/local/sap/nwrfcsdk' >> ~/.bashrc && . ~/.bashrc ENV SAPNWRFC_HOME=/usr/local/sap/nwrfcsdk RUN cd /etc/ld.so.conf.d/ && touch nwrfcsdk.conf && echo '/usr/local/sap/nwrfcsdk/lib' >> /etc/ld.so.conf.d/nwrfcsdk.conf RUN apt-get update && apt-get install -y python3-pip && ldconfig RUN ldconfig
COPY ./src ${RELEASE_DIR} COPY requirements.txt /tmp/ RUN pip3 install --requirement /tmp/requirements.txt
RUN rm /tmp/requirements.txt
WORKDIR ${RELEASE_DIR} ENV RELEASE_DIR ${RELEASE_DIR} ENV HOME=/home/agent
CMD ["python3", "-u", "test.py"] `
Requirements.txt:
requests pynwrfc
test.py inside src dir:
` from pyrfc import Connection import time
def check_config(host, sysnr, client, username, password): try: conn = Connection(ashost='host', sysnr='sysnr', client='client', user='username', passwd='password') print(conn) result = conn.call('STFC_CONNECTION', REQUTEXT=u'connection') if result['ECHOTEXT'] == "connection": return {"status": 101, "message": "Connected"} else: return {"status": 505, "message": "No resource found"} except Exception: pass
while True: print(check_config(host, sysnr, client, username, password)) time.sleep(2) `
It's working local on Ubuntu, but on our staging system theres a centos host and I get the host unknown error
Which PyRFC and which SAP NWRFC SDK are you using?
How your hostname unknown message looks like, does it show the ashost you use for testing or random string as described in initial issue above? If the hostname is correct it is a different issue and it looks like the backend system is not reachable from the staging system centos host. Could that be the case? Can you test the script from the staging system shell and post the error message?
Im using PyRFC 2.1.0 and SDK 7.50..
Heres the exception from the staging system:
The host name from the exception is the same name as the os name.. I am able to reach the ashost from the host system with the same code, but not from the container which is running on the host system..
Ok, that is definitely different issue. The hostname looks correct and PL5 is fine.
Could you please test if the ping cl4hana-base-vm
works from the staging system? If not, try to ping with cl4hana-base-vm ip address and/or replace the cl4hana-base-vm with the ip address in Python script and re-test.
cl4hana-base-vm is not the value of the ashost variable.. it's the os name of the host os.. The value of the ashost variable is a 192.168.x.x address
Can you test from the staging system console if the ping 192.168.x.x
works ?
ping from the staging system works..
Sorry, no idea than, The fact it works from one system and not from another sounds like a network issue, not related to PyRFC. I would suggest the Basis consultant or network admin check the configuration and test with SAP niping
utility from both systems.
But where the cl4hana-base-vm hostname come from? In python code the ashost variable has the value 192.168.x.x.. Should not be the error message something like "hostname '192.168.x.x unknown" ?
No idea about NWRFC SDK error messages. Could it be the staging system is running on a local VM? Configured in hosted instead of the bridged mode?
You can also check the staging system connectivity to backend, using niping utility. The parameters working for niping
work with PyRFC as well.
Changing the network mode worked for me.. but still no idea why the os-name of the host-os is in the error message.. Propably a SDK peculiarity.. Thank you for your efforts!!
I'm trying to execute my code in a different server, but I cannot manage to setup a connection using PyRFC. I suspect that there might be something setup erroneously in the network device.
Whever I attempt to create an instance of pyrfc.Connection, I get an error:
The host name displayed in the error message, is not actually the string I provide as the "ashost" parameter, and it seems to be a random string of numbers and letters. I get this error independently from whether the connection parameters I provide are correct or not. For contrast, if I attempt to create a connection with an erroneous host name, the error will show the erroneous name in the error message above.
The random string shown in the message error is different with every new container I run in the server, but within the same container, remains the same independently from what I provide as "ashost".
Performing a ping to the host name or the IP address from the same computer works correctly, so the server should be reachable.
The only similar issue I could find was https://github.com/SAP/PyRFC/issues/43 However, in that issue the provided host name is actually shown in the error message, so I don't think it's the same error.
Here's the rest of the error:
Environment Details PyRFC Version: 2.0.5 (Dockerfile pulls the current master branch of this repo) Base Image: python:3.7-buster Docker: Docker EE 19.03.5