-
Notifications
You must be signed in to change notification settings - Fork 416
Description
Hello,
I'm using asyncua==1.1.0 and trying to build an OPC UA server that performs monitoring. Specifically, I’d like to know when a client connects and when it reads or subscribes to data items. For this test, I'm running a server without authentication. The information I collect needs to be sent to a remote location.
I attempted to handle the following server callbacks:
self.server.subscribe_server_callback(
CallbackType.ItemSubscriptionCreated, self.create_monitored_items
)
self.server.subscribe_server_callback(
CallbackType.ItemSubscriptionModified, self.modify_monitored_items
)
self.server.subscribe_server_callback(
CallbackType.ItemSubscriptionDeleted, self.delete_monitored_items
)
self.server.subscribe_server_callback(
CallbackType.PostRead, self.read_monitored_items
)Inside these callbacks, I tried to identify which client triggered the event:
def modify_monitored_items(self, event, dispatcher):
# TODO: Somehow get client info
print(f"Modify monitored items by client: {client_info}")I can list connected clients through the BinaryServer connections, but I don’t see how to associate a specific client with a specific event (like a read or monitored item creation).
I’m not sure if I’m taking a completely wrong approach, but I started exploring this direction and would like to hear about possible alternatives. In short, my main questions are:
- Is there an existing way to retrieve client info (session, endpoint, or socket) inside these server callbacks?
- Also, is it possible to get socket information (like IP/port) when a client connects, even before any read or subscription occurs?