Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not receiving event after subscribe #1496

Open
Darkmagister opened this issue Dec 14, 2022 · 16 comments
Open

Not receiving event after subscribe #1496

Darkmagister opened this issue Dec 14, 2022 · 16 comments

Comments

@Darkmagister
Copy link

Describe the bug

i've used the client-event example to subscribe to node to get the events, the only difference is that i didn't pass the event type when i use the subscribe_event

To Reproduce

sys.path.insert(0, "..")

try:
    from IPython import embed
except ImportError:
    import code

    def embed():
        vars = globals()
        vars.update(locals())
        shell = code.InteractiveConsole(vars)
        shell.interact()


from opcua import Client

from opcua.tools import uals

class SubHandler(object):

    """
    Subscription Handler. To receive events from server for a subscription
    data_change and event methods are called directly from receiving thread.
    Do not do expensive, slow or network operation there. Create another
    thread if you need to do such a thing
    """
    def event_notification(self, event):
        print("New event recived: ", event)


if __name__ == "__main__":

    client = Client("opc.tcp://192.168.0.5:8119/")
    try:
        client.connect()

        # Client has a few methods to get proxy to UA nodes that should always be in address space such as Root or Objects
        root = client.get_root_node()
        print("root node is: ", root)

        # Now getting a variable node using its browse path
        obj  = client.get_node('ns=2;s=Notification/Messages')
        print("Objects node is: ", obj)

        msclt = SubHandler()
        sub = client.create_subscription(100, msclt)
        handle = sub.subscribe_events(obj)

        embed()
        sub.unsubscribe(handle)
        sub.delete()
    finally:
        client.disconnect()

Expected behavior

wiev print New event recived: ... but getting nothing

Version

Python-Version:3.8.6

python-opcua Version (e.g. master branch, 0.9): 0.98.9

@AndreasHeine
Copy link
Member

does it work with UAExpert? screenshot?

@Darkmagister
Copy link
Author

does it work with UAExpert? screenshot?

yes in ua expert i can see the events, i don't know what kind of screenshot is usefull to you ...
immagine

also if i do the same with the opcua-client i subscribe to event of the same node i don't get anything

@AndreasHeine
Copy link
Member

can you turn on the logger and look if there is any hint or issue according to the event?

@AndreasHeine
Copy link
Member

you can also try to:

handle = sub.subscribe_events() # empty it uses server object so all events of the server

@Darkmagister
Copy link
Author

can you turn on the logger and look if there is any hint or issue according to the event?

sorry but what do you me turn on logger ??

@Darkmagister
Copy link
Author

you can also try to:

handle = sub.subscribe_events() # empty it uses server object so all events of the server

i only got this events:

New event recived:  Event(["EventId:b',\\xfb5\\x8cq\\xf4RE\\x9d\\x99\\x07&\\\\7\\xa7\\xb0'", 'EventType:FourByteNodeId(i=2071)', 'SourceNode:NumericNodeId(ns=7;i=1004304931)', 'SourceName:Pure Python Client Session1', 'Time:2022-12-14 10:42:01.518655', 'ReceiveTime:2022-12-14 10:42:01.518655', 'LocalTime:None', 'Message:LocalizedText(Encoding:3, Locale:en-US, Text:Session Pure Python Client Session1 created.)', 'Severity:300'])
New event recived:  Event(["EventId:b'\\xf3\\x9d\\xc2|\\xb4\\xeaEI\\x94\\xcfg\\xd2\\xc4\\x962;'", 'EventType:FourByteNodeId(i=2071)', 'SourceNode:NumericNodeId(ns=7;i=1004304987)', 'SourceName:Pure Python Client Session1', 'Time:2022-12-14 10:43:01.587090', 'ReceiveTime:2022-12-14 10:43:01.587090', 'LocalTime:None', 'Message:LocalizedText(Encoding:3, Locale:en-US, Text:Session Pure Python Client Session1 created.)', 'Severity:300'])
New event recived:  Event(["EventId:b'\\xc6\\xd5$.\\x9an\\x1fG\\xbf\\xf0n0\\x11\\xfc\\xd0\\x1c'", 'EventType:FourByteNodeId(i=2071)', 'SourceNode:NumericNodeId(ns=7;i=1004305043)', 'SourceName:Pure Python Client Session1', 'Time:2022-12-14 10:44:01.653526', 'ReceiveTime:2022-12-14 10:44:01.653526', 'LocalTime:None', 'Message:LocalizedText(Encoding:3, Locale:en-US, Text:Session Pure Python Client Session1 created.)', 'Severity:300'])
New event recived:  Event(["EventId:b'\\xbd\\x87\\xb6\\xc1\\x81\\xb56C\\x98]\\xb2\\x91\\x16\\x87\\x87\\n'", 'EventType:FourByteNodeId(i=2071)', 'SourceNode:NumericNodeId(ns=7;i=1004305099)', 'SourceName:Pure Python Client Session1', 'Time:2022-12-14 10:45:01.721962', 'ReceiveTime:2022-12-14 10:45:01.721962', 'LocalTime:None', 'Message:LocalizedText(Encoding:3, Locale:en-US, Text:Session Pure Python Client Session1 created.)', 'Severity:300'])

that are pretty strange to me as they seems from the client and not from the server ... but no event from the server

@AndreasHeine
Copy link
Member

i made a few tests with your script against some demo-servers (Unified Automation Stack and node-opcua stack and it actually works...)

Unified Automation Stack (UaCppDemoServer):
image

node-opcua (opc.tcp://opcua.umati.app:4843):
image

Have you some additional information about the server!?

@Darkmagister
Copy link
Author

i don't know a lot is a software from a cnc machine but i have very little to none information, a getting it it's quite difficult as they don't give a lot of info ...

@Darkmagister
Copy link
Author

i made a few tests with your script against some demo-servers (Unified Automation Stack and node-opcua stack and it actually works...)

Unified Automation Stack (UaCppDemoServer): image

node-opcua (opc.tcp://opcua.umati.app:4843): image

Have you some additional information about the server!?

i've tried downloading the 1.7.7 cpp demo server from ua, but it doesn't work for me ... the only event i get if the python client session created ... i've never used the server demo is there something i have to do to generate an event ??

@AndreasHeine
Copy link
Member

AndreasHeine commented Dec 14, 2022

In the UaCpp server you need to trigger them!

image

or you can use a online server which has some demoevents implemented "opc.tcp://opcua.umati.app:4843"

@Darkmagister
Copy link
Author

In the UaCpp server you need to trigger them!

image

or you can use a online server which has some demoevents implemented "opc.tcp://opcua.umati.app:4843"

thanks, same result here now i tried to contact them telling that i can see the event from the uademoserver but not from their and let's see if something happen, thanks a lot i will update

i've also updated the opcua lib to 0.98.13 but same result

@Darkmagister
Copy link
Author

Darkmagister commented Dec 16, 2022

one little update is that i've tried using another library (while i'm waiting some useful info) node-opcua and that works ok, i receive the events normally

is there anything i can do to understand why is not working with this lib? any like debug option to get more info ? or any info from the node-opcua lib event that can be helpful?
(i don't know if can be any useful but the node-opcua need to have endpointMustExist: false as the serve give localhost as endpoint)

@AndreasHeine
Copy link
Member

that would take some time to find the issue! the main problem is to reproduce the behavior...

you could try opcua-asyncio (pip install asyncua) it the current active supported version and python-opcua is deprecated...

it has also a sync wrapper with very little api changes!

@Darkmagister
Copy link
Author

that would take some time to find the issue! the main problem is to reproduce the behavior...

you could try opcua-asyncio (pip install asyncua) it the current active supported version and python-opcua is deprecated...

it has also a sync wrapper with very little api changes!

I tried with the other lib the Asyncio and same behavior as this one ... So if there is anything I could try to get debug info it would be awesome ...
Otherwise I have to rede the communication part with another lib ... And that would take more time :)

@AndreasHeine
Copy link
Member

@Darkmagister can you try this:

FreeOpcUa/opcua-asyncio#1164 (comment)

@Darkmagister
Copy link
Author

@Darkmagister can you try this:

FreeOpcUa/opcua-asyncio#1164 (comment)

i tried using this: subscribe_alarms_and_conditions
instead of subscribe_events

but still same result no event show up, i haven't set the type because i'm not sure what is the nodeid of the message type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants