GithubHelp home page GithubHelp logo

Timeout Problems about gosnmp HOT 7 CLOSED

gosnmp avatar gosnmp commented on May 28, 2024
Timeout Problems

from gosnmp.

Comments (7)

wdreeveii avatar wdreeveii commented on May 28, 2024

There is no limit on what networks or interfaces this library will receive
on.

Can you please provide a code sample that demonstrates this problem? Your
tcpdump logs would also be helpful.

Thanks

On Thu, Oct 8, 2015 at 2:12 PM, Ipartner TI Experience <
[email protected]> wrote:

Hi.

Every time I try to pull data from a snmp agent it returns timeout if the
host (server) is in another network.

if the agent is in the same network it works fine.

tcpdump shows the petition and the response but the snmpget still jumps
with timeout error.
if the test run in a host from the same network the data comes ok.

tested snmpget (part of snmp-utils) and works w/o problems there is sime
limites over this library?


Reply to this email directly or view it on GitHub
#55.

Whitham D. Reeve II
907-764-5263

from gosnmp.

ipartner avatar ipartner commented on May 28, 2024

My code

package main

import (
"fmt"
"log"
"net"
"os"
"time"

"github.com/paulstuart/ping"
"github.com/soniah/gosnmp"

)

func main() {

var snmp gosnmp.GoSNMP
snmp.Target = "172.25.12.1" //pfsense box
snmp.Port = 161
snmp.Version = gosnmp.Version2c
snmp.Timeout = time.Duration(30) * time.Second
snmp.Community = "public"
snmp.Retries = 2
gosnmp.LoggingDisabled = false
fmt.Printf("Conectando\n")

ec := snmp.Connect()

if ec != nil {
    fmt.Printf("Error snmp %s\n", ec)
    return
}
fmt.Printf("Conectado\n")

result, error_get := snmp.Get([]string{".1.3.6.1.2.1.1.1.0"})
if error_get != nil {
    fmt.Printf("Error get %s \n", error_get, result)
    return
}

for _, v := range result.Variables {
    fmt.Printf("%+v\n", v)
    if v.Type != gosnmp.BitString {
        os := v.Value.([]byte)
        fmt.Printf("Nombre %s\n", v.Name, string(os))

    }
}

}

Output from my VM
root@localhost detector]# ./detector
Conectando
Conectado
logSNMP-2015/10/09 13:21:02 Retry number 1. Last error was: Error reading from UDP: read udp 172.25.12.1:161: i/o timeout
logSNMP-2015/10/09 13:21:12 Retry number 2. Last error was: Error reading from UDP: read udp 172.25.12.1:161: i/o timeout
logSNMP-2015/10/09 13:21:22 Retry number 3. Last error was: Error reading from UDP: read udp 172.25.12.1:161: i/o timeout
Error get Request timeout (after 2 retries)
%!(EXTRA *gosnmp.SnmpPacket=)

tcdump output
tcpdump -i eno16777736 port 161
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eno16777736, link-type EN10MB (Ethernet), capture size 65535 bytes
13:20:52.344549 IP 172.16.68.144.36898 > 172.25.12.1.snmp: GetRequest(28) system.sysDescr.0
13:20:52.419162 IP 10.0.8.1.snmp > 172.16.68.144.36898: GetResponse(107) system.sysDescr.0="pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386"
13:21:02.346104 IP 172.16.68.144.36898 > 172.25.12.1.snmp: GetRequest(28) system.sysDescr.0
13:21:02.414936 IP 10.0.8.1.snmp > 172.16.68.144.36898: GetResponse(107) system.sysDescr.0="pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386"
13:21:12.347555 IP 172.16.68.144.36898 > 172.25.12.1.snmp: GetRequest(28) system.sysDescr.0
13:21:12.391494 IP 10.0.8.1.snmp > 172.16.68.144.36898: GetResponse(107) system.sysDescr.0="pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386"

Snmpget runing in the same box
snmpget -v2c -c public 172.25.12.1 .1.3.6.1.2.1.1.1.0
SNMPv2-MIB::sysDescr.0 = STRING: pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386
tcpdump output

13:23:27.516676 IP 172.16.68.144.51095 > 172.25.12.1.snmp: GetRequest(28) system.sysDescr.0
13:23:27.569517 IP 10.0.8.1.snmp > 172.16.68.144.51095: GetResponse(107) system.sysDescr.0="pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386"

If the programs run on a machine in the same network that the pfsense box it works just fine,
the conection betwerrn the pf sense box is trough OpenVPN udpVPN, the test run from a VM with Fedora 20 and my MacBook with the same results.

from gosnmp.

ipartner avatar ipartner commented on May 28, 2024

Looking at the tcpdump(sorry I just noticed) it seems that the pfsense box responds from the vpn interface 10.0.8.1 and not from the target IP.

changed the target to that IP and it worked nicely. the weird thing is the origin and why snmpget worked, looks it intercepts any data that match even if its from other ip

from gosnmp.

abaluta avatar abaluta commented on May 28, 2024

I already wrote about this issue: #47

from gosnmp.

wdreeveii avatar wdreeveii commented on May 28, 2024

Abulata, from my interpretation, the people commenting on that issue liked
the proposed solution. Is there a reason you decided to close the issue?

On Thu, Oct 22, 2015 at 3:35 AM, abaluta [email protected] wrote:

I already wrote about this issue: #47
#47


Reply to this email directly or view it on GitHub
#55 (comment).

Whitham D. Reeve II
907-764-5263

from gosnmp.

abaluta avatar abaluta commented on May 28, 2024

wdreeveii, I decided to use another language (the library) in the project. It is an open source project, I do not pay money for it, and I can only offer. :)

from gosnmp.

wdreeveii avatar wdreeveii commented on May 28, 2024

Closing this issue as a duplicate of #47

from gosnmp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.