-
Notifications
You must be signed in to change notification settings - Fork 423
Description
My problem was very similar to the issue #1705, the code I'm using is in below:
` import asyncio
import logging
from asyncua import Client
logging.basicConfig(level=logging.INFO)
_logger = logging.getLogger(name)
class SubHandler:
def event_notification(self, event):
_logger.info("New event received: %r", event)
async def main():
url = "opc.tcp://10.9.132.14:4840"
client = Client(url=url)
# client.application_uri = "urn:localhost:engel:euromap77"
client.set_user("localuser1737xxxxxxxx")
client.set_password("xxxxxxxx")
async with client:
_logger.info("connection good!")
# Client has a few methods to get proxy to UA nodes that should always be in address space such as Root or Objects
_logger.info("Objects node is: %r", client.nodes.root)
# Now getting a variable node using its browse path
obj = await client.nodes.root.get_child(["0:Objects", "2:DeviceSet", "1:IMM_ENGEL_265552"])
_logger.info("MyObject is: %r", obj)
myevent = await client.nodes.root.get_child(["0:Types", "0:EventTypes", "0:BaseEventType", "3:CycleParametersEventType"])
print(myevent)
_logger.info("MyFirstEventType is: %r", myevent)
msclt = SubHandler()
sub = await client.create_subscription(100, msclt)
handle = await sub.subscribe_events(obj, myevent)
await asyncio.sleep(300)
await sub.unsubscribe(handle)
await sub.delete()
if name == "main":
asyncio.run(main())
`
And the error output is
WARNING:asyncua.client.client:Revised values returned differ from subscription values: CreateSubscriptionResult(SubscriptionId=46, RevisedPublishingInterval=100.0, RevisedLifetimeCount=81000, RevisedMaxKeepAliveCount=27000) sub works INFO:asyncua.client.ua_client.UaClient:browse WARNING:asyncua.uaprotocol:Received an error: ErrorMessage(Error=StatusCode(value=2147942400), Reason='Bad_DecodingError (code=0x80070000, description="Unexpected NodeId Encoding Byte -127")') CRITICAL:asyncua.client.ua_client.UASocketProtocol:Received an error: ErrorMessage(Error=StatusCode(value=2147942400), Reason='Bad_DecodingError (code=0x80070000, description="Unexpected NodeId Encoding Byte -127")') INFO:asyncua.client.ua_client.UASocketProtocol:Request to close socket received ERROR:asyncua.client.ua_client.UASocketProtocol:Got error status from server: Decoding halted because of invalid data in the stream.(BadDecodingError) INFO:asyncua.client.ua_client.UASocketProtocol:Request to close socket received INFO:asyncua.client.ua_client.UASocketProtocol:Socket has closed connection INFO:asyncua.client.client:disconnect INFO:asyncua.client.ua_client.UaClient:close_session WARNING:asyncua.client.ua_client.UaClient:close_session was called but connection is closed WARNING:asyncua.client.ua_client.UaClient:close_secure_channel was called but connection is closed WARNING:asyncua.client.ua_client.UaClient:disconnect_socket was called but connection is closed
I have use UaExpert to confirm the events are out putting from the server.
