Why is pysnmp sending a snmp trap as TCP and changing the port?

122 Views Asked by At

I'm sending a trap using pysnmp, but somehow the trap is getting there via TCP instead of UDP, and it is also changing the port, which I told it to use 162, but it's sending as 4222.

This is the code:

next(sendNotification(SnmpEngine(),
     CommunityData('public', mpModel=0),
     UdpTransportTarget(('ipv4', 162)),
     ContextData(),
     'trap',
     
     [ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0'), OctetString('TEST TEST TEST'))]))

I have no idea why this is happening. Any thoughts?

1

There are 1 best solutions below

3
Prudhviraj Panisetti On

It looks like the IP address is not correct for UdpTransportTarget()

or

try giving transportAddr=('127.0.0.1', 162)

 UdpTransportTarget(transportAddr=('127.0.0.1', 162)),