Article

From:
To:
=?Utf-8?Q?Pierre_Dupr=C3=A8s?=
Subject:
Re: Problem with IdSNMP Trap [Edit]
Newsgroup:
embarcadero.public.delphi.internet.winsock

Re: Problem with IdSNMP Trap [Edit]

> {quote:title=Pierre Dupr__s wrote:}{quote}
> Here is the wireshark capture as asked, note that the trap is well in snmp v1 format, but shoes an OID named "snmpv2-smi", hope you won't misunderstood this and believe trap is in snmp v2 format !! (I do myself think that this OID name isn't very clever and can be confusing if the reader of the trap doesn't know traps frames format...).
> 
> The link : http://a.imageshack.us/img808/8808/capturewireshark.jpg
> 
> NB : I have also desactivated my firewall, but nothing has changed.
Do you see an "ICMP destination unreachable (Port unreachable)" sent back on receiving a SNMP trap ? This means your IdSNMP was not listening on port 162, please check with "netstat -an -p udp" in command prompt. You must set the property snmp.BoundPort = 162 so that it is listening on this port and can process snmp trap meassage.

> {quote:title=Pierre Dupr__s wrote:}{quote}
> OK thanks for All Remy. At least now I know (and my boss too) that we can't receive traps for the moment with this component.
>
If the idsnmp still does not work, please try to update Indy, see this topic https://forums.embarcadero.com/thread.jspa?messageID=226925
Packages *70.pkg may be suitable for Delphi7

This is my code to receive trap, press button bbtStart to start, the IdSNMP is on form (no need to call Create). Trap will be processed continuously, real-time, no need to use a timer.
{code:delphi}
// -----------------------------------------------------------------------------
procedure TfrmMain.bbtStartClick(Sender: TObject);
begin
  snmp.BoundPort := 162;  // the most important, to listen to snmp trap
  snmp.ReceiveTimeout := 100;
  snmp.Active := True;
  bbtStart.Enabled := False;
  bbtStop.Enabled := not bbtStart.Enabled;
  while snmp.Active do
  begin
    while snmp.ReceiveTrap = 1 do
    if snmp.Trap.Version = 0  then ProcessTrapv1(snmp.Trap); // process here
    Sleep(1); // if does not sleep, process will consume 100% CPU
    Application.ProcessMessages; // to allow user to press button Stop
  end;
end;
// -----------------------------------------------------------------------------
procedure TfrmMain.bbtStopClick(Sender: TObject);
begin
  snmp.Active := False;
  bbtStart.Enabled := True;
  bbtStop.Enabled := not bbtStart.Enabled;
end;
{code}
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Fri, 01 Nov 2024 00:05:47 UTC
Copyright © 2009-2024
HREF Tools Corp.