pysnmp icon indicating copy to clipboard operation
pysnmp copied to clipboard

AttributeError: 'UdpTransportTarget' object has no attribute 'contextName'

Open rohitsanthan opened this issue 3 years ago • 1 comments

Hi, I am getting the error mentioned in the title when trying to run the below script. Could you please help with this? g = getCmd(SnmpEngine(), CommunityData("private"), UsmUserData('private', authKey='authkey1', privKey='authkey1', authProtocol=hlapi.usmHMACMD5AuthProtocol, privProtocol=hlapi.usmAesCfb128Protocol), UdpTransportTarget(('10.1.1.254', 161)), ContextData(), ObjectType(ObjectIdentity('1.3.6.1.4.1.9.9.23.1.3.1')))

rohitsanthan avatar Jul 16 '22 20:07 rohitsanthan

Your syntax for calling getCmd is incorrect. It seems you have mixed up Comm String along with UsmUserData which, by position, pushes UdpTransportTarget to that of ContextData parameter, and hence the error when it looks for contextName.

Please follow the correct usage for v3 and you will have it working.

Reference: https://pysnmp.readthedocs.io/en/latest/examples/hlapi/v3arch/asyncore/sync/manager/cmdgen/snmp-versions.html

stsojithomas avatar Aug 23 '22 01:08 stsojithomas