[SNMP4J] Freezing when creating an Snmp object
Norman Elton
normelton at gmail.com
Wed Jun 15 16:13:45 CEST 2005
It appears I've solved my problem. To summarize for anyone
experiencing this problem in the future...
SecureRandom.nextBytes() has been known to hang for up to 20 seconds.
A quick google-search will confirm this. It appears to be platform
dependent and relatively unpredictable.
To disable v2c and v3 support, I've used a different snmp constructor...
MessageDispatcher md = new MessageDispatcherImpl();
md.addMessageProcessingModel(new MPv1());
NewUdpTransportMapping transport = new NewUdpTransportMapping();
snmp = new Snmp(md, transport);
This allows me to pass in individual message processing models
without having to create a new snmp subclass.
Norman
On Jun 13, 2005, at 6:18 PM, Frank Fock wrote:
> Norman,
>
> May be it's the random bug then. Someone reported a problem
> with the random seed initializing function on a Linux distribution
> (Redhat?).
> The solution should be in the mailing list archive... somewhere...
>
> Best regards,
> Frank
>
> Norman Elton wrote:
>
>
>> Frank,
>>
>> I've copied the DefaultUdpTransportMapping to a new class and
>> have called SetReuseAddress(true) immediately after creating the
>> socket. This does not appear to fix the problem.
>>
>> Any other ideas?
>>
>> Thanks,
>>
>> Norman
>>
>>
>> On Jun 13, 2005, at 4:19 PM, Frank Fock wrote:
>>
>>
>>> Norman,
>>>
>>> I do not think that this problem is related to SNMP4J. What
>>> operating system are you using? There are some OS where
>>> reusing IP sockets may take some time. See Socket.setReuseAddress
>>> for more information on this. SNMP4J does not set this option.
>>> If you need it on your system, you may create your own transport
>>> mapping
>>> subclass.
>>>
>>> Best regards,
>>> Frank
>>>
>>> Norman Elton wrote:
>>>
>>>
>>>
>>>> I've got the following three lines of code...
>>>>
>>>> TransportMapping transport = new DefaultUdpTransportMapping();
>>>> snmp = new Snmp(transport);
>>>> transport.listen();
>>>>
>>>> For some reason, the code tends to hang for anywhere from 2-30
>>>> seconds after I call the second line. I've diagnosed this by
>>>> putting System.out calls in between each line.
>>>>
>>>> I've noticed that this problem is more reproducible if I
>>>> execute my program immediately after it stops. If I wait a few
>>>> minutes, the code runs as expected. I am calling snmp.close()
>>>> before exiting, to close any sockets and stop the listening
>>>> thread.
>>>>
>>>> Are there any other resources that need to be freed up? Is
>>>> there some case that would cause the Snmp constructor to hang?
>>>>
>>>> Thanks,
>>>>
>>>> Norman Elton
>>>>
>>>> _______________________________________________
>>>> SNMP4J mailing list
>>>> SNMP4J at agentpp.org
>>>> http://lists.agentpp.org/mailman/listinfo/snmp4j
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>
More information about the SNMP4J
mailing list