NolanPL has asked for the wisdom of the Perl Monks concerning the following question:

When I run my script, I get the Problem Transport endpoint is not connected Heres the code in question
($session, $error) = Net::SNMP->session( -hostname => $ip, -port => $port, -version => $version, -timeout => $seconds, -retries => $retry, -username => $username, -authpassword => $authpasswd, -authprotocol => $authproto, -privpassword => $privpasswd, -privprotocol => $privproto, ); die "Problem creating SNMP \n $error" if($error); #MIB Objects my $TransferServerOID = '.1.3.6.1.4.1.576.25.1.2.2.1'; my $TransferLoginNameOID = '.1.3.6.1.4.1.576.25.1.2.2.2'; my $TransferPasswordOID = '.1.3.6.1.4.1.576.25.1.2.2.3'; my $TransferCommandOID= '.1.3.6.1.4.1.576.25.1.2.2.7'; my $TransferManifestOID= '.1.3.6.1.4.1.576.25.1.2.2.8'; #Values to assign to MIB OBjects my $TransferServer = 'XXXXXX' ; my $TransferLogin = 'XXXXXX'; my $TransferPass = 'XXXXXXX'; my $TransferCommand = 1; #Set MIB Objects my $result = $session->set_request( -varbindlist =>[ ($TransferServerOID,OCTET_STRING,$T +ransferServer), ($TransferLoginNameOID,OCTET_STRING +,$TransferLogin), ($TransferPasswordOID,OCTET_STRING, +$TransferPass), ($TransferCommandOID,'HmsSysCommand +Type',$TransferCommand), ($TransferManifestOID,OCTET_STRING, +$wamfile), ]); die "SNMP Failure... $!" unless (defined($result));
Server, Login, Pass all X'd Out for privacy reasons Also, the SNMP Session is created correctly, and I have been able to do a simple get request to retrieve the uptime of the remote system. So I believe that it is not a problem with the SNMP creation.

Replies are listed 'Best First'.
Re: Net::SNMP Problem
by NetWallah (Canon) on Jul 02, 2008 at 18:33 UTC
    In your set_request, you are attempting to set multiple values.

    Looking at the code (PDU module), this is how it analyzes the trios:

    #-- the "-varbindlist' array ref is assigned to $trios my $pairs = []; for (my $i = 0; $i < $#{$trios}; $i += 3) { if ($trios->[$i] !~ /^\.?\d+\.\d+(?:\.\d+)*/) { return $this->_error('Expected OBJECT IDENTIFIER in dotted no +tation'); } push(@{$pairs}, OBJECT_IDENTIFIER, $trios->[$i], $trios->[$i+1], $trios->[$i+ +2] ); }
    Analyzing this, what it appears to be expecting is a SINGLE array ref containing triplets .. perhaps something like (untested):
    -varbindlist =>[ $TransferServerOID,OCTET_STRING,$Tr +ansferServer, $TransferLoginNameOID,OCTET_STRING, +$TransferLogin, $TransferPasswordOID,OCTET_STRING,$ +TransferPass, $TransferCommandOID,'HmsSysCommandT +ype',$TransferCommand, $TransferManifestOID,OCTET_STRING,$ +wamfile ]);
    UpdateAak! - ignore this nonsense - code scan malfunction - Your code is equivalent to my suggestion.

         Have you been high today? I see the nuns are gay! My brother yelled to me...I love you inside Ed - Benny Lava, by Buffalax

Re: Net::SNMP Problem
by monarch (Priest) on Jul 02, 2008 at 22:37 UTC
    Tricky problem, and I don't have any answers.

    I know for a fact that a single SNMP set request can have multiple varbinds, I've done this when configuring ATM circuits using Cisco WAN Manager using Net::SNMP for years.

    One question is what version of SNMP are you using? I'm suspecting v3 because of the authentication malarkey..

    Article SNMP Error using Net::SNMP - Transport endpoint is not connected doesn't appear to shed any light on the problem. For the most part SNMP is UDP, however I suspect v3 (because of security and encryption) could use TCP (in which case being connected to a Transport Endpoint actually has some meaning).

    Hunting through the internet I found Re: Samba, Howto eliminate the getpeername failed error message, which could have some meaning if you are using Windows XP. Looking through the source of Net::SNMP I could find no reference to the error message "Transport endpoint is not connected" so I'm guessing it is a system error related to the getpeername() function.

      Further to this, I suspect the remote side is dropping your TCP connection before or during the SNMP set request. Can you confirm this by running Wireshark (formally known as Ethereal) to determine if, indeed, the connection is dropped?

      Ask yourself why the remote end (server) might drop a connection - bad set request? Malformed packet? Timeout? Something else?

Re: Net::SNMP Problem
by glide (Pilgrim) on Jul 04, 2008 at 17:20 UTC
    Hi,

    When you hare making a get or set of a SNMP var, you need to had a tailing ".0" to the OID.

    ex:
    my $TransferManifestOID= '.1.3.6.1.4.1.576.25.1.2.2.8.0';