Reputation: 81
I am a biginer for Pysnmp . I just installed it and started study. When i work with example for Synchronous Command Generator i am getting an error that "No SNMP response received before timeout".Any one please help!! My code is
from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('localhost', 161)),
'1.3.6.1.2.1.1.1.0',
'1.3.6.1.2.1.1.6.0'
)
# Check for errors and print out results
if errorIndication:
print(errorIndication)
else:
if errorStatus:
print('%s at %s' % (
errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex)-1] or '?'
)
)
else:
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
Upvotes: 1
Views: 9794
Reputation: 11
OP didn't specify OS so if you're testing on Windows this may help:
Upvotes: 1
Reputation: 21
There is nothing wrong with your code but could be two possible reasons why you are getting that response.
your 'localhost' has no snmp configured in it. Try connecting to a device ip that has snmp configured.
your communityData string is not 'public' on the device(localhost).
Check these two things and lets see how it goes. if you do not have a device to work on then trying out GNS3 would be the best option.
Upvotes: 1
Reputation: 81
Corrected the issue by installing SNMP (on Linux OS) and changing its configuration file.
Upvotes: 1