HI,
I’m trying to get the ProxyForwarder working. I configure the MIBs according to the RFC which are:
SnmpTargetMIB, (Snmp Target Address table and Snmp Proxy Table)
and SnmpCommunityMIB (to translate snmpv2 Community to contextEngineID).
I created an entry for target address (UDP domain).
We issue an SNMP GET request using SNMP version 2.
The proxy forwarder correctly finds the Community string in the Community table and locates the SnmpProxyTable entry which points to the SnmpTargetAddress Table.
But when the forwarder attempts to forward the SNMP packet to the target, I get a NullPointerException. It appears that it is unable to retrieve the target address from the SnmpTargetAddress Table.
Log below:
2020-10-07 09:33:23,109 INFO [stdout] (DefaultUDPTransportMapping_127.0.0.1/161) 2020-10-07 09:33:23 INFO ProxyForwarderImpl:199 - Forwarding proxy request org.snmp4j.agent.ProxyForwardRequest[coexistenceInfo=CoexistenceInfo[securityName=public,contextEngineID=123456789012,contextName=,transportTag=],proxyType=1,commandEvent=CommandResponderEvent[securityModel=2, securityLevel=1, maxSizeResponsePDU=2147483647, pduHandle=PduHandle[1042], stateReference=StateReference[msgID=0,pduHandle=PduHandle[1042],securityEngineID=null,securityModel=null,securityName=public,securityLevel=1,contextEngineID=null,contextName=null,retryMsgIDs=null], pdu=GET[requestID=1042, errorStatus=Success(0), errorIndex=0, VBS[1.2.3.4.1.1.0 = Null]], messageProcessingModel=1, securityName=public, processed=false, peerAddress=127.0.0.1/54662, transportMapping=org.snmp4j.transport.DefaultUdpTransportMapping@6c437bc, tmStateReference=null]] to CommunityTarget[address=null,version=1,timeout=50000,retries=5,securityLevel=1,securityModel=1,securityName=public,preferredTransports=null]
2020-10-07 09:33:23,114 ERROR [stderr] (DefaultUDPTransportMapping_127.0.0.1/161) java.lang.NullPointerException
2020-10-07 09:33:23,119 ERROR [stderr] (DefaultUDPTransportMapping_127.0.0.1/161) at com.lmco.pts.pcos//org.snmp4j.MessageDispatcherImpl.getTransport(MessageDispatcherImpl.java:225)
…
Note the CommunityTarget ‘address=null’. This appears to be the cause of the NPE. I have the target address correctly defined in the target address table (6 bytes; IP address/port) but it cant seem to find it. We add the entry using targetMib.addTargetAddress(…).
We are using Snmp4J 2.5.3 with BaseAgent.
thanks
Bill R