Re: [pysnmp-users] [BUG] raise exception "PyAsn1Error: Invalid sub-ID in xxx" in some device with p
Brought to you by:
elie
From: Ilya E. <il...@gl...> - 2015-10-14 19:30:02
|
Hi Kim, That’s a curious error. I can’t easily reproduce it because it is triggered by some specific response from your printer (#2). Could you enable pysnmp debugging, rerun your test script against the bad IP/OID and send me the output? Thanks, ilya > On 12 Oct 2015, at 10:41, Kim,Young-Kyun <mar...@li...> wrote: > > Hi! > > Below is my test code. > When this code run with pysnmp 4.3.1(CVS version, 2015/10/12), > "PyAsn1Error: Invalid sub-ID in (2, '3837204320') at ObjectName" exception raised in some device. > This code works well with pysnmp 4.2.5 and 4.3.0. > > Test Environment: > OS : Windows 8.1 Enterprise 64bit > Python : CPython 2.7.10 32bit > > What's wrong? > > -------------------------------------------- > from pysnmp.entity.rfc3413.oneliner import cmdgen > > def snmpnext(ipaddr, oid): > community_data = cmdgen.CommunityData('my-agent', 'public', 0) > udp_trans_target = cmdgen.UdpTransportTarget(ipaddr) > return cmdgen.CommandGenerator().nextCmd(community_data,udp_trans_target, oid) > > def test(): > ipaddr1 = ("192.168.123.178", 161) > print "1-1=", snmpnext(ipaddr1, (1, 3, 6, 1, 2, 1, 2, 2, 1, 6)) > print "1-2=", snmpnext(ipaddr1, (1, 3, 6, 1, 2, 1, 1, 1)) > ipaddr2 = ("192.168.123.179", 161) > print "2-1=", snmpnext(ipaddr2, (1, 3, 6, 1, 2, 1, 2, 2, 1, 6)) > print "2-2=", snmpnext(ipaddr2, (1, 3, 6, 1, 2, 1, 1, 1)) # raise error with pysnmp 4.3.1 > > if __name__ == "__main__": > test() > -------------------------------------------- > > Below is detail log message. > -------------------------------------------- > 1-1= (None, Integer('noError', NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), ('badValue', 3), ('readOnly', 4), ('genErr', 5), ('noAccess', 6), ('wrongType', 7), ('wrongLength', 8), ('wrongEncoding', 9), ('wrongValue', 10), ('noCreation', 11), ('inconsistentValue', 12), ('resourceUnavailable', 13), ('commitFailed', 14), ('undoFailed', 15), ('authorizationError', 16), ('notWritable', 17), ('inconsistentName', 18))), Integer(0, subtypeSpec=ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(0, Integer(2147483647)))), [[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.2.2.1.6.1')), OctetString(''))], [ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.2.2.1.6.2')), OctetString(hexValue='00237d8b5d7a'))]]) > 1-2= (None, Integer('noError', NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), ('badValue', 3), ('readOnly', 4), ('genErr', 5), ('noAccess', 6), ('wrongType', 7), ('wrongLength', 8), ('wrongEncoding', 9), ('wrongValue', 10), ('noCreation', 11), ('inconsistentValue', 12), ('resourceUnavailable', 13), ('commitFailed', 14), ('undoFailed', 15), ('authorizationError', 16), ('notWritable', 17), ('inconsistentName', 18))), Integer(0, subtypeSpec=ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(0, Integer(2147483647)))), [[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.1.1.0')), DisplayString('HP ETHERNET MULTI-ENVIRONMENT,ROM none,JETDIRECT,JD146,EEPROM V.38.68,CIDATE 09/18/2008', subtypeSpec=ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(), ValueSizeConstraint(0, 65535)), ValueSizeConstraint(0, 255)), ValueSizeConstraint(0, 255))))]]) > 2-1= (None, Integer('noError', NamedValues(('noError', 0), ('tooBig', 1), ('noSuchName', 2), ('badValue', 3), ('readOnly', 4), ('genErr', 5), ('noAccess', 6), ('wrongType', 7), ('wrongLength', 8), ('wrongEncoding', 9), ('wrongValue', 10), ('noCreation', 11), ('inconsistentValue', 12), ('resourceUnavailable', 13), ('commitFailed', 14), ('undoFailed', 15), ('authorizationError', 16), ('notWritable', 17), ('inconsistentName', 18))), Integer(0, subtypeSpec=ConstraintsIntersection(ConstraintsIntersection(), ValueRangeConstraint(0, Integer(2147483647)))), [[ObjectType(ObjectIdentity(ObjectName('1.3.6.1.2.1.2.2.1.6.3')), OctetString(hexValue='d89d67eaf3eb'))]]) > 2-2= > Traceback (most recent call last): > File "test.py", line 20, in <module> > test() > File "test.py", line 17, in test > print "2-2=", snmpnext(ipaddr2, (1, 3, 6, 1, 2, 1, 1, 1)) > File "test.py", line 9, in snmpnext > return cmdgen.CommandGenerator().nextCmd(community_data,udp_trans_target, oid) > File "C:\devtool\py27x86\lib\site-packages\pysnmp\entity\rfc3413\oneliner\cmdgen.py", line 228, in nextCmd > **kwargs): > File "C:\devtool\py27x86\lib\site-packages\pysnmp\hlapi\asyncore\sync\cmdgen.py", line 348, in nextCmd > snmpEngine.transportDispatcher.runDispatcher() > File "C:\devtool\py27x86\lib\site-packages\pysnmp\carrier\asyncore\dispatch.py", line 41, in runDispatcher > raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info()))) > pysnmp.error.PySnmpError: poll error: Traceback (most recent call last): > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\carrier\asyncore\dispatch.py", line 37, in runDispatcher > use_poll=True, map=self.__sockMap, count=1) > ; File "C:\devtool\py27x86\lib\asyncore.py", line 220, in loop > poll_fun(timeout, map) > ; File "C:\devtool\py27x86\lib\asyncore.py", line 156, in poll > read(obj) > ; File "C:\devtool\py27x86\lib\asyncore.py", line 87, in read > obj.handle_error() > ; File "C:\devtool\py27x86\lib\asyncore.py", line 83, in read > obj.handle_read_event() > ; File "C:\devtool\py27x86\lib\asyncore.py", line 449, in handle_read_event > self.handle_read() > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\carrier\asyncore\dgram\base.py", line 145, in handle_read > self._cbFun(self, transportAddress, incomingMessage) > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\carrier\base.py", line 52, in _cbFun > self, transportDomain, transportAddress, incomingMessage > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\entity\engine.py", line 145, in __receiveMessageCbFun > self, transportDomain, transportAddress, wholeMsg > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\proto\rfc3412.py", line 529, in receiveMessage > cachedParams['cbCtx'] > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\entity\rfc3413\cmdgen.py", line 174, in processResponsePdu > cbCtx) > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\entity\rfc3413\cmdgen.py", line 407, in processResponseVarBinds > cbCtx): > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\hlapi\asyncore\cmdgen.py", line 362, in __cbFun > [ vbProcessor.unmakeVarBinds(snmpEngine, varBindTableRow, lookupMib) for varBindTableRow in varBindTable ], > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\hlapi\varbinds.py", line 37, in unmakeVarBinds > varBinds = [ ObjectType(ObjectIdentity(x[0]), x[1]).resolveWithMib(mibViewController) for x in varBinds ] > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\rfc1902.py", line 728, in resolveWithMib > self.__args[1] = ObjectIdentity(self.__args[1]).resolveWithMib(mibViewController) > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\rfc1902.py", line 361, in resolveWithMib > self.__oid > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\view.py", line 200, in getNodeNameByOid > nodeName, mibMod['oidToLabelIdx'], mibMod['labelToOidIdx'] > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\view.py", line 180, in __getOidLabel > nodeName[:-1], oidToLabelIdx, labelToOidIdx > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\view.py", line 180, in __getOidLabel > nodeName[:-1], oidToLabelIdx, labelToOidIdx > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\view.py", line 180, in __getOidLabel > nodeName[:-1], oidToLabelIdx, labelToOidIdx > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\view.py", line 180, in __getOidLabel > nodeName[:-1], oidToLabelIdx, labelToOidIdx > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\view.py", line 180, in __getOidLabel > nodeName[:-1], oidToLabelIdx, labelToOidIdx > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\view.py", line 180, in __getOidLabel > nodeName[:-1], oidToLabelIdx, labelToOidIdx > ; File "C:\devtool\py27x86\lib\site-packages\pysnmp\smi\view.py", line 183, in __getOidLabel > resLabel = label + tuple([ str(x) for x in suffix ]) > ; File "C:\devtool\py27x86\lib\site-packages\pyasn1\type\univ.py", line 497, in __add__ > def __add__(self, other): return self.clone(self._value + other) > ; File "C:\devtool\py27x86\lib\site-packages\pyasn1\type\base.py", line 117, in clone > return self.__class__(value, tagSet, subtypeSpec) > ; File "C:\devtool\py27x86\lib\site-packages\pyasn1\type\base.py", line 74, in __init__ > value = self.prettyIn(value) > ; File "C:\devtool\py27x86\lib\site-packages\pyasn1\type\univ.py", line 559, in prettyIn > 'Invalid sub-ID in %s at %s' % (value, self.__class__.__name__) > ;PyAsn1Error: Invalid sub-ID in (2, '3837204320') at ObjectName > |