FreeOpcUa / python-opcua

LGPL Pure Python OPC-UA Client and Server
http://freeopcua.github.io/
GNU Lesser General Public License v3.0
1.35k stars 658 forks source link

subscription stack trace in internal_subscription.deadband_callback #328

Closed bitkeeper closed 7 years ago

bitkeeper commented 7 years ago

Today I got a nice stack trace from a python-opcua server (at bottom of this message).

The problem is isolated to: D:\work\python-opcua\opcua\server\internal_subscription.py", line 209, in deadband_callback

   def deadband_callback(self, values, flt):
        if (values.get_old_value() is not None) or \
                ((abs(values.get_current_value() - values.get_old_value())) > flt.DeadbandValue):
            return True
        else:
            return False

When get values.get_old_value() is None you will get a exception. I guess the not in the if is a typo, but before I provide fix I want to be sure in case of None the return value should be True ?

ERROR:opcua.server.binary_server_asyncio:Exception raised while parsing message from client, closing
Traceback (most recent call last):
  File "D:\work\python-opcua\opcua\server\binary_server_asyncio.py", line 85, in _process_data
    ret = self.processor.process(hdr, buf)
  File "D:\work\python-opcua\opcua\server\uaprocessor.py", line 87, in process
    return self.process_message(msg.SecurityHeader(), msg.SequenceHeader(), msg.body())
  File "D:\work\python-opcua\opcua\server\uaprocessor.py", line 108, in process_message
    return self._process_message(typeid, requesthdr, algohdr, seqhdr, body)
  File "D:\work\python-opcua\opcua\server\uaprocessor.py", line 320, in _process_message
    results = self.session.create_monitored_items(params)
  File "D:\work\python-opcua\opcua\server\internal_server.py", line 347, in create_monitored_items
    subscription_result = self.subscription_service.create_monitored_items(params)
  File "D:\work\python-opcua\opcua\server\subscription_service.py", line 67, in create_monitored_items
    return self.subscriptions[params.SubscriptionId].monitored_item_srv.create_monitored_items(params)
  File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 69, in create_monitored_items
    result = self._create_data_change_monitored_item(item)
  File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 157, in _create_data_change_monitored_item
    self.trigger_datachange(handle, params.ItemToMonitor.NodeId, params.ItemToMonitor.AttributeId)
  File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 82, in trigger_datachange
    self.datachange_callback(handle, variant)
  File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 199, in datachange_callback
    deadband_flag_pass = self.deadband_callback(mdata.mvalue, mdata.filter)
  File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 209, in deadband_callback
    ((abs(values.get_current_value() - values.get_old_value())) > flt.DeadbandValue):
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
oroulet commented 7 years ago

Try git blame. And then ping the author. Otherwise we need to understand ;-)

On Thu, Oct 13, 2016, 22:42 Marcel notifications@github.com wrote:

Today I got a nice stack trace from a python-opcua server (at bottom of this message).

The problem is isolated to: D:\work\python-opcua\opcua\server\internal_subscription.py", line 209, in deadband_callback

def deadband_callback(self, values, flt): if (values.get_old_value() is not None) or \ ((abs(values.get_current_value() - values.get_old_value())) > flt.DeadbandValue): return True else: return False

When get values.get_old_value() is None you will get a exception. I guess the not in the if is a typo, but before I provide fix I want to be sure in case of None the return value should be True ?

ERROR:opcua.server.binary_server_asyncio:Exception raised while parsing message from client, closing Traceback (most recent call last): File "D:\work\python-opcua\opcua\server\binary_server_asyncio.py", line 85, in _process_data ret = self.processor.process(hdr, buf) File "D:\work\python-opcua\opcua\server\uaprocessor.py", line 87, in process return self.process_message(msg.SecurityHeader(), msg.SequenceHeader(), msg.body()) File "D:\work\python-opcua\opcua\server\uaprocessor.py", line 108, in process_message return self._process_message(typeid, requesthdr, algohdr, seqhdr, body) File "D:\work\python-opcua\opcua\server\uaprocessor.py", line 320, in _process_message results = self.session.create_monitored_items(params) File "D:\work\python-opcua\opcua\server\internal_server.py", line 347, in create_monitored_items subscription_result = self.subscription_service.create_monitored_items(params) File "D:\work\python-opcua\opcua\server\subscription_service.py", line 67, in create_monitored_items return self.subscriptions[params.SubscriptionId].monitored_item_srv.create_monitored_items(params) File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 69, in create_monitored_items result = self._create_data_change_monitored_item(item) File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 157, in _create_data_change_monitored_item self.trigger_datachange(handle, params.ItemToMonitor.NodeId, params.ItemToMonitor.AttributeId) File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 82, in trigger_datachange self.datachange_callback(handle, variant) File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 199, in datachange_callback deadband_flag_pass = self.deadband_callback(mdata.mvalue, mdata.filter) File "D:\work\python-opcua\opcua\server\internal_subscription.py", line 209, in deadband_callback ((abs(values.get_current_value() - values.get_old_value())) > flt.DeadbandValue):TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/FreeOpcUa/python-opcua/issues/328, or mute the thread https://github.com/notifications/unsubscribe-auth/ACcfzrtn4arR2S_1boRCOlLSgqzzVUKCks5qzpezgaJpZM4KWWGa .