Skip to content

Trap receiver throws exception #107

@aschamberger

Description

@aschamberger

Issue Description

I tried to implement a trap receiver and it raises the following exception:

Exception in callback _SelectorDatagramTransport._read_ready()
handle: <Handle _SelectorDatagramTransport._read_ready()>
Traceback (most recent call last):
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.9/asyncio/selector_events.py", line 1029, in _read_ready
    self._protocol.datagram_received(data, addr)
  File "/usr/local/lib/python3.9/dist-packages/puresnmp/transport.py", line 80, in datagram_received
    self.callback(SocketResponse(data, SocketInfo(addr[0], addr[1])))
  File "/usr/local/lib/python3.9/dist-packages/puresnmp/api/raw.py", line 903, in decode
    mproc = mpm.create(obj[0].value, handler, lcd)
TypeError: 'Integer' object is not subscriptable

My code:

import asyncio
from puresnmp import V1, V2C
from puresnmp.api.raw import register_trap_callback

port = 162
credentials = V2C('public')

def callback(trap)
    print(trap)

loop = register_trap_callback(callback, port=port, credentials=credentials)

async def main():
    while True:
        await asyncio.sleep(3600)

loop.run_until_complete(main())

HexDump

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions