Null Pointer Exception in MessageDispatcherImpl

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

I should also add, here is the data that is populated in the MIB tables:
SnmpTargetTable:
name = “ADDR_NAME_1”
Domain= “1.3.6.1.6.1.1” (UdpDomain)
Address = “192.168.2.2/161”
Timeout = 5000
retries = 5
tagList = “”
Params = “PARAMS_1”
storageType = 2

SnmpProxyTable
Name = “PROXY_1”
Type = Read
ContextEngineId = “123456789012”
ContextName = “”
TargetParamsIn = “PARAMS_1”
SingleTargetOut= “ADDR_NAME_1”
MultiTargetOut = “”
StorageType = 2

SnmpTargetParamsTable
Name = “PARAMS_1”
MPModel = 1
SecurityModel = 2
SecurityName = “public2”
SecurityLevel = 1
StorageType = 2

SnmpCommunityTable
Name = “COMM_1”
Community = “public2”
SecurityName = “public2”
ContextEngineId = “123456789012”
ContextName = “”
TransportTags = “”
storageType = 2

In the community MIB you add an entry for community “public2” but you send a packet with community “public”. There is no match - that’s all :slight_smile:

Thanks for the reply, sorry I pasted the wrong log output, we are sending the packet with ‘public2’ as community. Below is the correct log output. It shows that it is reading the correct target information, because I see the correct timeout and retry values (5000, 5) being posted. But the target address is null. Also, it finds the right engineId. I traced through the code and for some reason the target destAddress is null (and code doesn’t check for it) at MessageDispatcherImpl:225.

2020-10-08 08:05:39,147 INFO [stdout] (DefaultUDPTransportMapping_127.0.0.1/161) 2020-10-08 08:05:39 INFO ProxyForwarderImpl:199 - Forwarding proxy request org.snmp4j.agent.ProxyForwardRequest[coexistenceInfo=CoexistenceInfo[securityName=public2,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=public2,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=public2, processed=false, peerAddress=127.0.0.1/52089, transportMapping=org.snmp4j.transport.DefaultUdpTransportMapping@6e168aa0, tmStateReference=null]] to CommunityTarget[address=null,version=1,timeout=50000,retries=5,securityLevel=1,securityModel=1,securityName=public2,preferredTransports=null]

2020-10-08 08:05:39,149 ERROR [stderr] (DefaultUDPTransportMapping_127.0.0.1/161) java.lang.NullPointerException

2020-10-08 08:05:39,154 ERROR [stderr] (DefaultUDPTransportMapping_127.0.0.1/161) at com.lmco.pts.pcos//org.snmp4j.MessageDispatcherImpl.getTransport(MessageDispatcherImpl.java:225)

2020-10-08 08:05:39,165 ERROR [stderr] (DefaultUDPTransportMapping_127.0.0.1/161) at com.lmco.pts.pcos//org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:446)

–Bill R

OK I figured out the problem i cited with MessageDispatcher.
It drops the IP address cause it doesn’t recognize the TDomain.
We have to register the address type (TDomain) with addSupportedTdomain. Otherwise it drops the IP address silently.
Got it working now thanks.
Code should check for missing IP address in the target and log an error.
Bill R