I have a device where the snmpget command from Linux terminal works flawlessly. Using snmpget I can read variables from my device. But when I use the getCmd from inside my python code, it answers with "No SNMP response received before timeout". The python script works well with other devices, but with one of them it doesn't answer to my requests. I activated the pysnmp debug using "setLogger(Debug('io','msgproc'))". In this way I can see that the device answers correctly to the oid query, but after the answer I can see many error messages. In the following I report part of the log:
2023-07-26 20:35:48,197 pysnmp: prepareDataElements: Message:
version=version-2c
community=ro_user
data=PDUs:
response=ResponsePDU:
request-id=8075824
error-status=noError
error-index=0
variable-bindings=VarBindList:
VarBind:
name=1.3.6.1.4.1.43768.3.1.1.8.2.8.2.7.0
=_BindValue:
value=ObjectSyntax:
simple=SimpleSyntax:
integer-value=-154
2023-07-26 20:35:48,198 pysnmp: StatusInformation: {'errorIndication': UnknownCommunityName('Unknown SNMP community name encountered',)}
2023-07-26 20:35:48,198 pysnmp: StatusInformation: {'errorIndication': UnknownCommunityName('Unknown SNMP community name encountered',)}
2023-07-26 20:35:48,198 pysnmp: StatusInformation: {'errorIndication': UnknownCommunityName('Unknown SNMP community name encountered',)}
2023-07-26 20:35:48,198 pysnmp: StatusInformation: {'errorIndication': UnknownCommunityName('Unknown SNMP community name encountered',)}
2023-07-26 20:35:48,198 pysnmp: StatusInformation: {'errorIndication': UnknownCommunityName('Unknown SNMP community name encountered',), 'communityName': <OctetString value object, tagSet <TagSet object, tags 0:0:4>, encoding iso-8859-1, payload [ro_user]>}
2023-07-26 20:35:48,198 pysnmp: StatusInformation: {'errorIndication': UnknownCommunityName('Unknown SNMP community name encountered',), 'communityName': <OctetString value object, tagSet <TagSet object, tags 0:0:4>, encoding iso-8859-1, payload [ro_user]>}
2023-07-26 20:35:48,198 pysnmp: StatusInformation: {'errorIndication': UnknownCommunityName('Unknown SNMP community name encountered',), 'communityName': <OctetString value object, tagSet <TagSet object, tags 0:0:4>, encoding iso-8859-1, payload [ro_user]>}
2023-07-26 20:35:48,198 pysnmp: StatusInformation: {'errorIndication': UnknownCommunityName('Unknown SNMP community name encountered',), 'communityName': <OctetString value object, tagSet <TagSet object, tags 0:0:4>, encoding iso-8859-1, payload [ro_user]>}
2023-07-26 20:35:50,701 pysnmp: StatusInformation: {'errorIndication': RequestTimedOut('No SNMP response received before timeout',)}
2023-07-26 20:35:50,701 pysnmp: StatusInformation: {'errorIndication': RequestTimedOut('No SNMP response received before timeout',)}
2023-07-26 20:35:50,701 pysnmp: StatusInformation: {'errorIndication': RequestTimedOut('No SNMP response received before timeout',)}
2023-07-26 20:35:50,701 pysnmp: StatusInformation: {'errorIndication': RequestTimedOut('No SNMP response received before timeout',)}
Why the errors if I have the correct answer (-154) for my oid variable? Can I fix this problem? I read other similar questions on Stackoverflow, but none of them answers to my question
Thank you in advance
I tried to use snmpget to test if the device is online and it is responding. I expect that the getCmd command answers with varBinds, without "No SNMP response" errors
[EDIT]
I run a tcpdump for the network operation and the dump is the following:
[ec2-user@ip-XX-XX-XX-136 txControl]$ sudo tcpdump -nn -vv -s0 -A host YY.YY.YY.30 and udp
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
10:30:15.639669 IP (tos 0x0, ttl 255, id 9132, offset 0, flags [DF], proto UDP (17), length 80) XX.XX.XX.136.60645 > YY.YY.YY.30.161: [bad udp cksum 0x35f0 -> 0x44c6!] { SNMPv2c { GetRequest(37) R=11271142 .1.3.6.1.4.1.43768.3.1.1.8.2.8.2.2.0 } } E..P#.@..."N....%.c......<5.02.....public.%............0.0...+......x...........
10:30:15.686773 IP (tos 0x0, ttl 43, id 47225, offset 0, flags [DF], proto UDP (17), length 83) YY.YY.YY.30.161 > XX.XX.XX.136.60645: [udp sum ok] { SNMPv2c C="ro_user" { GetResponse(39) R=11271142 .1.3.6.1.4.1.43768.3.1.1.8.2.8.2.2.0=5495 } } E..S.y@.+.a~%.c..........?.#05.....ro_user.'............0.0...+......x............w
I don't see anything strange...
The sript simply does the following:
def construct_object_types(list_of_oids):
object_types = []
for oid in list_of_oids:
object_types.append(ObjectType(ObjectIdentity(oid)))
return object_types
snmpData=getCmd(
SnmpEngine(),
CommunityData('public', mpModel=1),
UdpTransportTarget(
('YY.YY.YY.30',161),
timeout=2.5, #2
retries=0), #2
ContextData(),
*construct_object_types(['.1.3.6.1.4.1.43768.3.1.1.8.2.8.2.2.0']),
lookupMib=False,
lexicographicMode=False
)