Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max no of 200 conversations exceeded error in PyRFC

Tags:

python

abap

pyrfc

I am getting this error from the PyRFC library:

Traceback (most recent call last):
...
  File "/.../sap_connection.py", line 486, in get_connection
    return Connection(**get_connection_dict(contact_host))
  File "src/pyrfc/_pyrfc.pyx", line 182, in pyrfc._pyrfc.Connection.__init__
  File "src/pyrfc/_pyrfc.pyx", line 226, in pyrfc._pyrfc.Connection._open
  File "src/pyrfc/_pyrfc.pyx", line 256, 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 with Unicode
ERROR       max no of 200 conversations exceeded
TIME        Wed Dec  4 13:53:22 2019
RELEASE     753
COMPONENT   CPIC (TCP/IP) with Unicode
VERSION     3
RC          466
MODULE      /bas/753_REL/src/krn/si/cpic/r3cpic.c
LINE        15830
COUNTER     201
 [MSG: class=, type=, number=, v1-4:=;;;]

Up to now I create a lot Connection instances and never explicitly close them.

If the Python process starts again (via linux cron job), then the RFC call works fine.

What should I do:

  • close the Connection explicitly?
  • reuse the Connection?
  • something else?

Related issue: https://github.com/SAP/PyRFC/issues/150

like image 380
guettli Avatar asked Sep 17 '25 07:09

guettli


2 Answers

There are SAP notes exists about this error. It says there is limit on server side and you need to limit your client. Note 316877 included server side parameter for increasing size.
It make sense to close connection. Because RFC working on TCP/IP level, it hasn't got auto close routine after response look like rest/http.

like image 113
mkysoft Avatar answered Sep 18 '25 20:09

mkysoft


I use this StatelessConnection now:

from pyrfc import Connection
class StatelessConnection(Connection):
    def call(self, rfc_name, **kwargs):
        try:
            return super(StatelessConnection, self).call(rfc_name, **kwargs)
        finally:
            self.close()

The performance might be a bit lower, but it makes the overall handling a lot easier.

... I compared the performance. How much do you loose if you close the connection after every call?

for i in range(1000):
    #conn.close()
    print(i, conn.call('RFC_PING'))

The duration was equal on my system - with "close()" and without "close()": 28 seconds.

Maybe it would make sense to make StatelessConnection the default in PyRFC?

like image 27
guettli Avatar answered Sep 18 '25 21:09

guettli