Skip to content

Commit 7d89908

Browse files
committed
Added check for None on NotificationData
NotificationData is sometimes None. And that causes an exception that breaks the flow and no SubscriptionAcknowledgement is created and published to the server.
1 parent c10f7d4 commit 7d89908

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

opcua/common/subscription.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,18 @@ def publish_callback(self, publishresult):
104104
while self.subscription_id is None:
105105
time.sleep(0.01)
106106

107-
for notif in publishresult.NotificationMessage.NotificationData:
108-
if isinstance(notif, ua.DataChangeNotification):
109-
self._call_datachange(notif)
110-
elif isinstance(notif, ua.EventNotificationList):
111-
self._call_event(notif)
112-
elif isinstance(notif, ua.StatusChangeNotification):
113-
self._call_status(notif)
114-
else:
115-
self.logger.warning("Notification type not supported yet for notification %s", notif)
107+
if publishresult.NotificationMessage.NotificationData is not None:
108+
for notif in publishresult.NotificationMessage.NotificationData:
109+
if isinstance(notif, ua.DataChangeNotification):
110+
self._call_datachange(notif)
111+
elif isinstance(notif, ua.EventNotificationList):
112+
self._call_event(notif)
113+
elif isinstance(notif, ua.StatusChangeNotification):
114+
self._call_status(notif)
115+
else:
116+
self.logger.warning("Notification type not supported yet for notification %s", notif)
117+
else:
118+
self.logger.warning("NotificationMessage is None.")
116119

117120
ack = ua.SubscriptionAcknowledgement()
118121
ack.SubscriptionId = self.subscription_id

0 commit comments

Comments
 (0)