FreeOpcUa / python-opcua

LGPL Pure Python OPC-UA Client and Server
http://freeopcua.github.io/
GNU Lesser General Public License v3.0
1.33k stars 661 forks source link

BadTooManyPublishRequests #1442

Open scch1092 opened 2 years ago

scch1092 commented 2 years ago

Hi all, I don't know if the error has already appeared, but I get an error when subscribing. The error appears when I subscribe again after unsubscribing. I use a PLC from Beckhoff, which runs an OPC-UA server. I guess the PLC is causing problems, but how can I work around this?

The error: "" ServiceFault from server received while waiting for publish response exception calling callback for <Future at 0x2622e82fb48 state=finished returned Buffer> Traceback (most recent call last): File "C:\Users\Chris\AppData\Local\Programs\Python\Python37\lib\concurrent\futures_base.py", line 324, in _invoke_callbacks callback(self) File "C:\Users\Chris\AppData\Local\Programs\Python\Python37\lib\site-packages\opcua\client\ua_client.py", line 493, in _call_publish_callback self._uasocket.check_answer(data, "while waiting for publish response") File "C:\Users\Chris\AppData\Local\Programs\Python\Python37\lib\site-packages\opcua\client\ua_client.py", line 93, in check_answer hdr.ServiceResult.check() File "C:\Users\Chris\AppData\Local\Programs\Python\Python37\lib\site-packages\opcua\ua\uatypes.py", line 218, in check raise UaStatusCodeError(self.value) opcua.ua.uaerrors._auto.BadTooManyPublishRequests: "The server has reached the maximum number of queued publish requests."(BadTooManyPublishRequests) ""

Furthermore: sub.delete() does not work either and only returns an error: "ServiceFault from server received while waiting for publish response"

Python 3.7.4 opcua==0.98.13 on windows

Thanks for the help!

AndreasHeine commented 2 years ago

hey, indeed ServiceFault is a response from the OPC UA Server! one way to work around it would be by disconnecting and reconnect then subscribe again (forces the server to delete all subs from that client/session) another way could be to wait for one keepalive-cycle before resubscribing.

fyi: -publish requests get stored if no notification is in the queue (till keepalive, if queue still empty!) -plc's have only limited ressources so it might be that you can have only a few of them (check the opc ua part of the manual -> "Number of Subscriptions" or "Subscriptions per Session" ...)

scch1092 commented 2 years ago

Oh wow, the answer came quickly! I will have to find out how this is implemented on the PLC. I will have to try it out. Thanks!

scch1092 commented 2 years ago

Hello, I have experimented a bit and found that despite an error message in the console, the subscription is still accepted. At the same time, they work as intended and without errors. I enclose the whole error message.

ServiceFault from server received while waiting for publish response exception calling callback for <Future at 0x2f61947ebc8 state=finished returned Buffer> Traceback (most recent call last): File "c:\users\chris\appdata\local\programs\python\python37\lib\concurrent\futures\_base.py", line 324, in _invoke_callbacks callback(self) File "c:\users\chris\appdata\local\programs\python\python37\lib\site-packages\opcua\client\ua_client.py", line 493, in _call_publish_callback self._uasocket.check_answer(data, "while waiting for publish response") File "c:\users\chris\appdata\local\programs\python\python37\lib\site-packages\opcua\client\ua_client.py", line 93, in check_answer hdr.ServiceResult.check() File "c:\users\chris\appdata\local\programs\python\python37\lib\site-packages\opcua\ua\uatypes.py", line 218, in check raise UaStatusCodeError(self.value) opcua.ua.uaerrors._auto.BadTooManyPublishRequests: "The server has reached the maximum number of queued publish requests."(BadTooManyPublishRequests)

AndreasHeine commented 2 years ago

without knowing what happens before the beckhof opc ua server responds with "BadTooManyPublishRequests" its a guessinggame... opt:

  1. enable debugger and post the relevant output or
  2. make a wiresharktrace of the error to see whats going on
imaginaryBuddy commented 2 months ago

Hi, following up on this, is there any way we can catch this server status? Because I would like to have an exception handling to timeout for a bit if I receive BadTooManyPublishRequests. Appreciate the help :)