{"action":"created","issue":{"url":"https://api.github.com/repos/FreeOpcUa/python-opcua/issues/652","repository_url":"https://api.github.com/repos/FreeOpcUa/python-opcua","labels_url":"https://api.github.com/repos/FreeOpcUa/python-opcua/issues/652/labels{/name}","comments_url":"https://api.github.com/repos/FreeOpcUa/python-opcua/issues/652/comments","events_url":"https://api.github.com/repos/FreeOpcUa/python-opcua/issues/652/events","html_url":"https://github.com/FreeOpcUa/python-opcua/issues/652","id":342757287,"node_id":"MDU6SXNzdWUzNDI3NTcyODc=","number":652,"title":"Uncaught InvalidSignature error","user":{"login":"axelfaure","id":41439694,"node_id":"MDQ6VXNlcjQxNDM5Njk0","avatar_url":"https://avatars1.githubusercontent.com/u/41439694?v=4","gravatar_id":"","url":"https://api.github.com/users/axelfaure","html_url":"https://github.com/axelfaure","followers_url":"https://api.github.com/users/axelfaure/followers","following_url":"https://api.github.com/users/axelfaure/following{/other_user}","gists_url":"https://api.github.com/users/axelfaure/gists{/gist_id}","starred_url":"https://api.github.com/users/axelfaure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axelfaure/subscriptions","organizations_url":"https://api.github.com/users/axelfaure/orgs","repos_url":"https://api.github.com/users/axelfaure/repos","events_url":"https://api.github.com/users/axelfaure/events{/privacy}","received_events_url":"https://api.github.com/users/axelfaure/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-19T14:38:43Z","updated_at":"2018-08-20T08:09:08Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\n\r\nI use python-opcua (0.98.3) to create a client which subscribes to datachanges on several nodes. (Thank you to every contributor for the work you put in this package by the way, it proves very useful !)\r\n\r\nMore often than not, after 7 or 8 minutes a problem occures where a signature fails to be validated and the library raise an InvalidSignature error.\r\nI don't know if the signature error in itself comes from python-opcua or from the server (but it is not simply random so if someone else faces this problem you may consider creating a dedicated issue).\r\n\r\nThe main problem in my opinion is that this InvalidSignature exception is never caught by the library and since it is in a child thread, it's very hard to catch for the user. As a result, the child thread crashes, soon after that a second crash occures (TimeoutError) (not caught either), and the main thread is never notified that the connexion is no longer working.\r\n\r\nHere are the two exceptions I receive:\r\n```\r\nException in thread Thread-2:\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python2.7/threading.py\", line 801, in __bootstrap_inner\r\n    self.run()\r\n  File \"/usr/lib/python2.7/threading.py\", line 754, in run\r\n    self.__target(*self.__args, **self.__kwargs)\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/client/ua_client.py\", line 95, in _run\r\n    self._receive()\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/client/ua_client.py\", line 104, in _receive\r\n    msg = self._connection.receive_from_socket(self._socket)\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/common/connection.py\", line 309, in receive_from_socket\r\n    return self.receive_from_header_and_body(header, ua.utils.Buffer(body))\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/common/connection.py\", line 280, in receive_from_header_and_body\r\n    header, body)\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/common/connection.py\", line 55, in from_header_and_body\r\n    crypto.verify(header_to_binary(obj.MessageHeader) + struct_to_binary(obj.SecurityHeader) + decrypted, signature)\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/crypto/security_policies.py\", line 155, in verify\r\n    self.Verifier.verify(data, sig)\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/crypto/security_policies.py\", line 276, in verify\r\n    raise uacrypto.InvalidSignature\r\nInvalidSignature\r\n\r\nException in thread Thread-3:\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python2.7/threading.py\", line 801, in __bootstrap_inner\r\n    self.run()\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/client/client.py\", line 62, in run\r\n    val = server_state.get_value()\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/common/node.py\", line 148, in get_value\r\n    result = self.get_data_value()\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/common/node.py\", line 157, in get_data_value\r\n    return self.get_attribute(ua.AttributeIds.Value)\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/common/node.py\", line 266, in get_attribute\r\n    result = self.server.read(params)\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/client/ua_client.py\", line 304, in read\r\n    data = self._uasocket.send_request(request)\r\n  File \"/home/user/.local/lib/python2.7/site-packages/opcua/client/ua_client.py\", line 77, in send_request\r\n    data = future.result(self.timeout)\r\n  File \"/home/user/.local/lib/python2.7/site-packages/concurrent/futures/_base.py\", line 464, in result\r\n    raise TimeoutError()\r\nTimeoutError\r\n```\r\n\r\nI managed to create a workaround where I catch exceptions from every thread in my software. But I think the library should definitely catch these exceptions (and really any exception raised in secondary threads) and offer some way for the user to detect that something wrong occured (maybe something as simple as a threading.Event)."},"comment":{"url":"https://api.github.com/repos/FreeOpcUa/python-opcua/issues/comments/414233113","html_url":"https://github.com/FreeOpcUa/python-opcua/issues/652#issuecomment-414233113","issue_url":"https://api.github.com/repos/FreeOpcUa/python-opcua/issues/652","id":414233113,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDIzMzExMw==","user":{"login":"satheesh90","id":17014676,"node_id":"MDQ6VXNlcjE3MDE0Njc2","avatar_url":"https://avatars3.githubusercontent.com/u/17014676?v=4","gravatar_id":"","url":"https://api.github.com/users/satheesh90","html_url":"https://github.com/satheesh90","followers_url":"https://api.github.com/users/satheesh90/followers","following_url":"https://api.github.com/users/satheesh90/following{/other_user}","gists_url":"https://api.github.com/users/satheesh90/gists{/gist_id}","starred_url":"https://api.github.com/users/satheesh90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/satheesh90/subscriptions","organizations_url":"https://api.github.com/users/satheesh90/orgs","repos_url":"https://api.github.com/users/satheesh90/repos","events_url":"https://api.github.com/users/satheesh90/events{/privacy}","received_events_url":"https://api.github.com/users/satheesh90/received_events","type":"User","site_admin":false},"created_at":"2018-08-20T08:09:08Z","updated_at":"2018-08-20T08:09:08Z","author_association":"NONE","body":"Hi, @axelfaure , did you solve this issue? I'm facing the same issue since last few days. Couldn't debug it!"}}
{"actor":{"display_login":"satheesh90"}}