'PySNMP Fetch SNMP variable

I have used following code snippet to get SNMP variable but always I am getting No SNMP response received before timeout . No firewall was enabled and got same error when tried in my personal laptop . does demo.snmplabs.com is working ? please advice. is there any other fetch snmp details ? Sample code from https://pysnmp.readthedocs.io/en/latest/quick-start.html

from pysnmp.hlapi import *



iterator = getCmd(
    SnmpEngine(),
    CommunityData('public', mpModel=0),
    UdpTransportTarget(('demo.snmplabs.com', 161)),
    ContextData(),
    ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))
)

errorIndication, errorStatus, errorIndex, varBinds = next(iterator)

if errorIndication:
    print(errorIndication)

elif errorStatus:
    print('%s at %s' % (errorStatus.prettyPrint(),
                        errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))

else:
    for varBind in varBinds:
        print(' = '.join([x.prettyPrint() for x in varBind]))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source