[SNMP4J] snmp4j and UdpPortUnreachable

Frank Fock fock at agentpp.com
Sat Feb 16 13:04:59 CET 2013


OK, now I understand you better. You want to use the ICMP message send 
by the target server
which indicates that the port is unreachable where the UDP SNMP message 
was sent to.
Java throws a PortUnreachableException if the command sender tries to 
send a second
UDP packet to the destination which responded with a ICMP not reachable.
There is no guarantee that Java will throw that exception for many reasons.

SNMP4J handles an PortUnreachableException and immediatly returns from a 
sync
request or calls the onResponse method of an async request callback.
If the exception occurs when sending the initial SNMP request (not with 
an retry),
the Snmp.send method throws the PortUnreachableException.

Thus, I do not see how the behavior can be improved by SNMP4J.

Best regards,
Frank

Am 16.02.2013 01:15, schrieb vitz me:
>   Of course it is not. Since UDP is a connectionless protocol, ICMP is used to report errors, such as port unreachable for it. I'm just trying to perform some simple SNMP get/getnext requests, and since the port my code is trying to connect to on the destination host may be closed, I do not want to wait for the timeout, but just kill the code as soon as I get the port unreachable message.. Of course this will not work for the filtered ports.. But if the port on the target host is closed and the ICMP message is receive I though there should be a way in snmp4j to process it (well actually I thought the api should handle these type of errors and not wait for the timeouts, but it seems that it still does)..
>
> Суббота, 16 февраля 2013, 0:57 +01:00 от Frank Fock <fock at agentpp.com>:
>> Hi,
>>
>> ICMP is not UDP. Which peer should send what message and which peer
>> closes the socket.
>> I am confused...
>>
>> Best regards,
>> Frank
>>
>> Am 16.02.2013 00:52, schrieb vitz me:
>>>    Hello,
>>> Thanks for the reply. I probably used wrong wording here (as I have seen something like UdpPortUnreachable exception in Java).. But still there should be an ICMP port unreachable message (type 3, code 3) in case if UDP port is closed (and not filtered; RFC 792 if I'm not mistaken)...which in turn should make it possible to process the message and not wait for the timeouts.. Please, correct me if I'm wrong...
>>> Thanks..
>>>
>>>
>>> Пятница, 15 февраля 2013, 23:47 +01:00 от Frank Fock < fock at agentpp.com >:
>>>> Hi,
>>>>
>>>> It seems that you mix up connection oriented communication (TCP) with
>>>> connection less (UDP).
>>>> With UDP you will never know if a target port is reachable or if the
>>>> application listening on the
>>>> target port is not responding. In both cases you simply wait forever for
>>>> a response (=timeout).
>>>>
>>>> Thus, there is no need to change SNMP4J.
>>>>
>>>> Best regards,
>>>> Frank
>>>>
>>>>
>>>> Am 15.02.2013 16:30, schrieb vitz me:
>>>>> I'm a beginner with Java and SNMP and trying to perform simple get requests. I faced an issue when the connection timeouts seem to still have an effect, even though the port specified for SNMP connection is closed on the target host.
>>>>> Is it possible to somehow process the UdpPortUnreachable (exception) within snmp4j? So that if the port is closed the timeout setting would not have any effect. Or what could be a way for getting around this problem?
>>>>> The only way I could think of was trying to check the port using Java sockets before even trying to send SNMP requests..
>>>>> Thanks.
>>>>> _______________________________________________
>>>>> SNMP4J mailing list
>>>>>   SNMP4J at agentpp.org
>>>>>   http://lists.agentpp.org/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
>>>>   http://lists.agentpp.org/mailman/listinfo/snmp4j
>>> _______________________________________________
>>> SNMP4J mailing list
>>>   SNMP4J at agentpp.org
>>>   http://lists.agentpp.org/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
>> http://lists.agentpp.org/mailman/listinfo/snmp4j
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/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