[SNMP4J] TcpAddress issue

joe.sulewski at L-3com.com joe.sulewski at L-3com.com
Thu May 7 15:38:15 CEST 2015


Frank,

I have that line in my code before I ever allocate an SNMP object and I'm still getting the same failure.  Below is a simplified version of my code:

private void initializeSNMP(boolean udp)
{
		SNMP4JSettings.setExtensibilityEnabled(false);
			
		if (udp)
			transport = new DefaultUdpTransportMapping(new UdpAddress(NetTools.getLocalIPAddress() + "/0"));
		else{
			TcpAddress address = new TcpAddress(Inet4Address.getByName(NetTools.getLocalIPAddress()),1161);
			transport = new DefaultTcpTransportMapping(address);
		}
		
		snmp = new Snmp(transport);
		transport.listen();
}

private void myCallingFunction()
{
		ResponseEvent event = null;

		initializeSNMP(true);
		snmpSettings.setSNMPPort(1161);
		targetAddress = GenericAddress.parse("TCP:" + snmpSettings.getAddress() + "/" + snmpSettings.getSNMPPort());
		
		target = new CommunityTarget();
		target.setCommunity(new OctetString(snmpSettings.getCommunity()));
		target.setAddress(targetAddress);
		target.setRetries(snmpSettings.getRetries());
		target.setTimeout(snmpSettings.getTimeout());
		target.setVersion(SnmpConstants.version2c);

		event = snmp.get(pdu, getTarget(snmpSettings));
}

When udp is set to true, the above works, when set to false it fails.  

ERROR: NNFactory.getNN(192.168.50.91, null) IOException1 = Dead Node
org.snmp4j.transport.UnsupportedAddressClassException: Unsupported address class (transport mapping): org.snmp4j.smi.TcpAddress
	at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:430)
	at org.snmp4j.Snmp.sendMessage(Snmp.java:1004)
	at org.snmp4j.Snmp.send(Snmp.java:898)
	at org.snmp4j.Snmp.send(Snmp.java:878)
	at org.snmp4j.Snmp.send(Snmp.java:843)
	at org.snmp4j.Snmp.get(Snmp.java:555)


Thanks,
Joe

-----Original Message-----
From: Frank Fock [mailto:fock at agentpp.com] 
Sent: Wednesday, May 06, 2015 6:04 PM
To: Sulewski, Joseph @ CSG - TE; snmp4j at agentpp.org
Subject: Re: [SNMP4J] TcpAddress issue

Hi Joe,

This issue seems to be caused by a class loader issue.
Please call

SNMP4JSettings.setExtensibilityEnabled(false);

Before you instantiate any address. That should solve the problem.

Best regards,
Frank

Am 06.05.2015 um 17:30 schrieb joe.sulewski at L-3com.com:
> Frank,
>
> Sorry for the delay, I am now just able to get back to this problem. 
> Here is the stack trace as it applies to your code
>
> Attempting to log messenger into UDPS Server at: 127.0.0.1
> org.snmp4j.transport.UnsupportedAddressClassException: Unsupported address class (transport mapping): org.snmp4j.smi.TcpAddress
> 	at org.snmp4j.MessageDispatcherImpl.sendPdu(MessageDispatcherImpl.java:430)
> 	at org.snmp4j.Snmp.sendMessage(Snmp.java:1004)
> 	at org.snmp4j.Snmp.send(Snmp.java:898)
> 	at org.snmp4j.Snmp.send(Snmp.java:878)
> 	at org.snmp4j.Snmp.send(Snmp.java:843)
> 	at org.snmp4j.Snmp.get(Snmp.java:555)
> 	
>
> Joe
>
> -----Original Message-----
> From: SNMP4J [mailto:snmp4j-bounces at agentpp.org] On Behalf Of Frank 
> Fock
> Sent: Thursday, April 30, 2015 11:11 AM
> To: snmp4j at agentpp.org
> Subject: Re: [SNMP4J] TcpAddress issue
>
> Hi Joe,
>
> There is no obvious error in what you wrote. So could you please provide us the SNMP4J related part of the stack trace? This might help to find the root cause.
>
> What happened in the past was often when people tried to test a simple 
> setup, that the main thread finished and closed the Snmp class 
> (stopping all transport
> listeners) before the request was send out. But since you seem to be using a synchronous call, this seems to be unlikely here.
>
> Best regards,
> Frank
>
> Am 30.04.2015 um 15:28 schrieb joe.sulewski at L-3com.com:
>> Hello,
>>
>> I'm trying to send data over TCP due to some parts of our network that have high unreliability.  I'm using version 2.2.3 of the SNMP4J library and I'm getting an error trying to send over tcp.
>>
>> I setup the TransportMapping like so:
>> TcpAddress address = new
>> TcpAddress(Inet4Address.getByName(NetTools.getLocalIPAddress()),1161)
>> ; transport = new DefaultTcpTransportMapping(address);
>>
>> SNMP4JSettings.setExtensibilityEnabled(false);
>> snmp = new Snmp(transport);
>> transport.listen();
>>
>>
>> To send data I perform the following:
>> snmpSettings.setSNMPPort(1161);
>> targetAddress = GenericAddress.parse("TCP:" +
>> snmpSettings.getAddress() + "/" + snmpSettings.getSNMPPort());
>>
>> target = new CommunityTarget();
>> target.setCommunity(new OctetString(snmpSettings.getCommunity()));
>> target.setAddress(targetAddress);
>> target.setRetries(snmpSettings.getRetries());
>> target.setTimeout(snmpSettings.getTimeout());
>> target.setVersion(SnmpConstants.version2c);
>>
>> snmp.get(pdu, target);
>>
>> The get throws the following error: Unsupported address class 
>> (transport mapping): org.snmp4j.smi.TcpAddress
>>
>> When I run in the debugger I looked at the snmp variable and the snmp->messageDispatcher->transportMappings table is:
>> {class
>> org.snmp4j.smi.TcpAddress=[org.snmp4j.transport.DefaultTcpTransportMa
>> p
>> ping at 969d5c]}
>>
>> The SNMP object appears to be setup correctly but yet I get the 
>> unsupported address class.  I must be missing something obvious
>>
>> I appreciate any pointers.
>>
>> Thanks,
>> Joe
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> https://oosnmp.net/mailman/listinfo/snmp4j
> --
> ---
> AGENT++
> Maximilian-Kolbe-Str. 10
> 73257 Koengen, Germany
> https://agentpp.com
> Phone: +49 7024 8688230
> Fax:   +49 7024 8688231
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> https://oosnmp.net/mailman/listinfo/snmp4j

--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231



More information about the SNMP4J mailing list