FreeOpcUa / opcua-asyncio

OPC UA library for python >= 3.7
GNU Lesser General Public License v3.0
1.12k stars 361 forks source link

Error: Number of acknowledgement results (0) does not match number of acknowledgements (1) #438

Open droneconnect opened 3 years ago

droneconnect commented 3 years ago

I am new to opcua-asyncio. Just installed it with pip3 install asyncua I run python 3.8.5 on ubuntu 20.04

I run the https://github.com/FreeOpcUa/opcua-asyncio/blob/master/examples/server-minimal.py and getting an error in uaexpert 1.5.1

could anyone advice? BR Dan

msg uaexpert

yichenj commented 3 years ago

Same issue. It seems a legacy issue from the sync version. I am looking forward to the fix plan.

AndreasHeine commented 3 years ago

looks like there is a ack or statuscode missing... it actually does not do any bad you still get the notifications in ua expert!

request:

subscription   Acknowledgements [ ] | Subscription Acknowledgement | The list of acknowledgements for one or more Subscriptions. This list may contain multiple acknowledgements for the same Subscription (multiple entries with the same subscriptionId). This structure is defined in-line with the following indented items.

response:

results [ ] | StatusCode | List of results for the acknowledgements (see 7.34 for StatusCode definition). The size and order of the list matches the size and order of the subscriptionAcknowledgements request parameter.

edit:

it appears results is always empty...

swamper123 commented 3 years ago

I went back with our versions until v0.9.0, but the issue still exist. So the newer commits haven't made any influence on that.

EDIT: @brubbel mentioned in python-opcua

The way freeopcua works at the moment is that datachanges are published whenever data changes (throttled and multiple changes are bundeled at regular intervals), however this implies that e.g. 2 or more datachange publication-responses may be sent to the client while the client expects a sequential PublishResult.Results for each ack in the publish request, in the order they were issued by the client (flaw in the OPCUA spec imho).

oroulet commented 3 years ago

What is an acknowledgement result? And do we do something wrong?

AndreasHeine commented 3 years ago

https://reference.opcfoundation.org/v104/Core/docs/Part4/5.13.5/

publish response -> results is empty but it must have same number of statuscodes like the number of subscriptionAcknowledgements

oroulet commented 3 years ago

I had a short look at it and in fact looks like we have a parsing bug and something very strange with the statuscode implementation. There is both an enum and a class. And enum should be more than enough i suppose... Must look at it later

droneconnect commented 3 years ago

good stuff! thanks guys for quickly troubleshooting this :).. give us an update when we can test again!

AndreasHeine commented 3 years ago

you can use it anyways that bug does not break anything you will recv all notifications in UA Expert! just kind of ugly in the log...

yichenj commented 3 years ago

Sorry, is this the same issue with the sync version? The sync one looks very complicated and can cause severe result based on the implementation of client.

oroulet commented 3 years ago

@AndreasHeine @swamper123 I tried to do something yesterday: Send results immediatly after receiving acks (2 acks in PublishRequest-> 2 statuscode results in next PublishResponse) But it does not seem to make uaexpert happy. I am not really sure what it wants...

oroulet commented 3 years ago

I am wondering if uaexpert expects the status code in the PublishResponse corresponding to the PublishRequest, but that would be orthogonal to the entire pub/sub system.... We keep a queue/buffer of PublishRequests in server

AndreasHeine commented 3 years ago

@oroulet this is from another server with node-opcua stack: screenshot packets trace1.zip

brubbel commented 3 years ago

I went back with our versions until v0.9.0, but the issue still exist. So the newer commits haven't made any influence on that.

That is because UaExpert only started reporting this in the logs in the more recent versions.

Don't try to decode my answer below word by word (it's been a long time for me), but basically it goes as follows.

  1. client sends publication request, which acts a 'token' for the server to send a future datachange.
  2. server sends datachange notification (consumes token), pushes a 'pending ack' in an ordered list.
  3. client sends new publication request (thus a new token), with embedded ack for notification in (2) Now comes the issue:
  4. server sends new datachange notification, with resulting statuscode 'good' after processing the client's ack in (3), then server removes that ack from the list mentioned in (2)

So the idea is here:

Freeopcua does not implement the token/acking whatever thing. Current implementation of freeopcua is to send datachange events when it feels to (=wrong!)

ps: acks are the NotificationMessage.SequenceNumber

Changes required in freeopcua, section internal subscription:

samxu0823 commented 3 years ago

I have met the same problem with opcua 0.98.13 and UaExpert1.5.1. Is there a solution right now? Thank you and looking forward to your answer!

AndreasHeine commented 3 years ago

any exception or error? or just the log in uaexpert?

samxu0823 commented 3 years ago

only log in UaExpert

AndreasHeine commented 3 years ago

do not worry!