Open f3lixTRS opened 2 years ago
Maybe you can try out #980?
I'm confused. You are talking about the server reporting for the first time on first change. "Change" implies that you're talking about monitoring a Variable Value. "Reporting" implies that that is the mode you've set said data change subscription to. In that case, shouldn't you receive an initial update on successful subscribe? At any rate Spec part 4 indicates that reporting is disabled otherwise. This has been discussed elsewhere already (the logic referenced there can be found here. Therefore, I'd expect that the first actual change report actually triggers the second event invocation. Or, that the MonitoringMode isn't such that any events whatsoever are to be expected, in which case it may be that this creates a loophole where the session just times out? (Sounds weird, but would it be consistent with the framework's assumptions about what a subscription would do, given that it's sensible to expect the only subscription to be Reporting?)
WARNING:asyncua.client.ua_client.UASocketProtocol:ServiceFault (BadSessionIdInvalid, diagnostics: DiagnosticInfo(SymbolicId=None, NamespaceURI=None, Locale=None, LocalizedText=None, AdditionalInfo=None, InnerStatusCode=None, InnerDiagnosticInfo=None)) from server received in response to PublishRequest ERROR:asyncua.client.client:Error while renewing session Traceback (most recent call last): File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\client.py", line 413, in _renew_channel_loop await self.open_secure_channel(renew=True) File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\client.py", line 306, in open_secure_channel result = await self.uaclient.open_secure_channel(params) File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\ua_client.py", line 280, in open_secure_channel return await self.protocol.open_secure_channel(params) File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\ua_client.py", line 213, in open_secure_channel await asyncio.wait_for(self._send_request(request, message_type=ua.MessageType.SecureOpen), self.timeout) File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\ua_client.py", line 134, in _send_request self.transport.write(msg) AttributeError: 'NoneType' object has no attribute 'write'
My understanding of this stack trace is that the TCP socket on the client side is getting closed (i.e: because self.transport
is now None). Therefore, the next attempt of the client to communicate with the server fails and raises an Exception (here, it happens when the client renews the secure_channel, which isn't surprising because this background call is fired frequently).
This usually happens because there's a problem with the underlying TCP connection. In order to make progress troubleshooting this, I would recommend you to start with a wireshark/tcpdump capture to find what causes the TCP socket to close unexpectedly (timeout, RESET sent by the server, etc..).
Hello wise people,
This is my first interaction with github and asyncua, so if a make some mistakes, be patient with me.
I'm tying to make a subscription to an opcua server (in fact it works) but I found two problems along the way.
(i) Sometimes, when a change happends in the server (e.g. one sensor starts to comunicate for first time) I receive an error and the connection closes:
WARNING:asyncua.client.ua_client.UASocketProtocol:ServiceFault (BadSessionIdInvalid, diagnostics: DiagnosticInfo(SymbolicId=None, NamespaceURI=None, Locale=None, LocalizedText=None, AdditionalInfo=None, InnerStatusCode=None, InnerDiagnosticInfo=None)) from server received in response to PublishRequest ERROR:asyncua.client.client:Error while renewing session Traceback (most recent call last): File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\client.py", line 413, in _renew_channel_loop await self.open_secure_channel(renew=True) File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\client.py", line 306, in open_secure_channel result = await self.uaclient.open_secure_channel(params) File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\ua_client.py", line 280, in open_secure_channel return await self.protocol.open_secure_channel(params) File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\ua_client.py", line 213, in open_secure_channel await asyncio.wait_for(self._send_request(request, message_type=ua.MessageType.SecureOpen), self.timeout) File "C:\Users\user1\Python\Python39\lib\site-packages\asyncua\client\ua_client.py", line 134, in _send_request self.transport.write(msg) AttributeError: 'NoneType' object has no attribute 'write'
(ii) When this error happends, the sesion doesn't close well, and in the server, the connection keeps (I only have a limited allowed connections).
My code is: ---------------------------------------- CODE START
---------------------------------------- CODE END
How I can treat this problem? If this problem is not avoidable, How can I close the session and the subscription in a proper way?
Thanks in advance guys.