Giter VIP home page Giter VIP logo

Comments (7)

phemmer avatar phemmer commented on May 16, 2024 1

This is expected. Because UDP is a connectionless protocol, there's no actual connection created. The Connect() method simply creates and opens the socket. Until something is sent across it, you don't know that the remote host is there and responding.
Even if you were able to detect that the remote host is there on Connect(), it could go away by the time you sent something. And it could also come back again at any time.

from gosnmp.

soniah avatar soniah commented on May 16, 2024

I'm overseas at the moment, can I
look it later?

On 15 June 2016 at 20:10, Toni Moreno [email protected] wrote:

Hi @soniah https://github.com/soniah . I'm building some improvements
in mi snmpcollector, I would like detect when snmp device is offline to try
do periodic re-connections.

When doing the first connection it returns non nil value , but my snmpd
daemon is stopped

https://github.com/toni-moreno/snmpcollector/blob/master/pkg/snmp.go#L172

After when trying to do a bulkwalk the client detects errors.

INFO[0000] First SNMP connection to host hostsnmpv3b stablished <--here first gosnmp.Connect()
INFO[0000] Filter not found for measurement:i linux_cpu
INFO[0000] Loading Indexed values in : linux_ports
FATA[0000] SNMP bulkwalk error Error reading from UDP: read udp 127.0.0.1:55412->127.0.0.1:161: read: connection refused

Can you review if I'm doing something wrong ?

Thank you very much


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#65, or mute the thread
https://github.com/notifications/unsubscribe/AADbJmx1pBjrn4cy6SE8e_1NHVGxhkEqks5qMIZZgaJpZM4I24d5
.

from gosnmp.

toni-moreno avatar toni-moreno commented on May 16, 2024

yes of course! thank you !!

from gosnmp.

rossmobi avatar rossmobi commented on May 16, 2024

@phemmer is correct. UDP is stateless, so unless you build your own 'connection' construct on top of it, all you get when you 'Connect()' is a listening socket where you can send data and where you can try and receive data.

What I suspect you would want to do is attempt to poll the device; if it returns an error or a value, then you can consider it online.

I'd suggest this issue is closed.

from gosnmp.

soniah avatar soniah commented on May 16, 2024

Closed - see comments about UDP being stateless. Thank you @toni-moreno @phemmer @schotlandzegtja for your request and comments :-)

from gosnmp.

toni-moreno avatar toni-moreno commented on May 16, 2024

Hi @phemmer and @soniah IMHO if we are working only with a connectionless protocol the gonsmp.Connect() is not a good API Method name, could be better something like gosnmp.PrepareProtocol()

When I did the first Connect() I expect the method can do something in the server side to give me an idea that server side is ok.

IMHO the documentation also give us an erroneous idea on what this method does.

https://godoc.org/github.com/soniah/gosnmp#GoSNMP.Connect

What do you think about?

from gosnmp.

soniah avatar soniah commented on May 16, 2024

Thank you Toni. I've updated the documentation:

Connect creates and opens a socket. Because UDP is a connectionless protocol, you won't know if the remote host is responding until you send packets. And if the host is regularly disappearing and reappearing, you won't know if you've only done a Connect().

For historical reasons (ie this is part of the public API), the method won't be renamed.

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.