snmppysnmp

pysnmp v1arch SnmpDispatcher() not throwing No SNMP response received before timeout


Generally pysnmp v3arch.asyncio SnmpEngine throws No SNMP response received before timeout if passed agent details are invalid or fake. But in the case of pysnmp v1arch.asyncio SnmpDispatcher is not throwing any error indications, and then the code gets stuck at the get_cmd call. Please help me to resolve this issue.

import asyncio
from pysnmp.hlapi.v1arch.asyncio import *


async def run():
    errorIndication, errorStatus, errorIndex, varBinds = await get_cmd(
        SnmpDispatcher(),
        CommunityData("public"),
        await UdpTransportTarget.create(("172.80.23.23", 161)),
        ObjectType(ObjectIdentity("SNMPv2-MIB", "sysDescr", 0)),
    )
    print(errorIndication, errorStatus, errorIndex, varBinds)


asyncio.run(run())

Solution

  • Next time you should report such to https://github.com/lextudio/pysnmp/issues

    This is a known issue that Ilya wasn't able to fully finish v1arch APIs. You just happened to hit a gap where timeout wasn't handled properly.

    Now it is fixed in release 7.1.20. You can upgrade and try again.