Git Product home page Git Product logo

Comments (13)

lewatt23 avatar lewatt23 commented on July 26, 2024 1

@BenMenking Just want to say thanks for this lib it saves my life

from routeros-api.

BenMenking avatar BenMenking commented on July 26, 2024

Looking at those lines, I'm suspecting that the socket is no longer valid (possibly false). Ideally we would check for socket validity before the fwrite() and then handle any errors appropriately at that point.

Another possibility is that connect() was not called before write() is being called. Regardless, write() should check for a valid socket and protest much if invalid.

from routeros-api.

scottchiefbaker avatar scottchiefbaker commented on July 26, 2024

I just realized that I was connecting to the wrong IP. In this case we were never able to connect at all... so we should add some tests that look for:

if (!$this->connected) {
    return false;
}

Before each call to read/write?

from routeros-api.

BenMenking avatar BenMenking commented on July 26, 2024

Well, as I've been thinking about this, I'm wondering if we should also change connect() to only attempt once instead of multiple times. Let the caller of connect() handle errors, which more than likely can't be fixed by multiple attempts.

Adding a socket validity check should be done. Represent errors in the form of exceptions?

from routeros-api.

BenMenking avatar BenMenking commented on July 26, 2024

Additionally, connect() should have returned false which the calling needs to trap and handle. Maybe use an exception so it's pretty clear there was a fatal error.

from routeros-api.

scottchiefbaker avatar scottchiefbaker commented on July 26, 2024

I agree with everything you said. It's my fault for not handling connect() properly... but the library should also not toss a bunch of warnings if things go haywire.

from routeros-api.

BenMenking avatar BenMenking commented on July 26, 2024

Fully agree. I'll see what I can do here in the next hour or so.

from routeros-api.

scottchiefbaker avatar scottchiefbaker commented on July 26, 2024

For what it's worth... we've got over 1000 hEX's deployed now and we use this library to talk to all of them. It works great!

from routeros-api.

BenMenking avatar BenMenking commented on July 26, 2024

Great to hear! Maybe we can make some good incremental improvements during 2017 too :)

from routeros-api.

scottchiefbaker avatar scottchiefbaker commented on July 26, 2024

Now that we're relying on it more I'm sure I'll have some pull requests for you this year.

from routeros-api.

BenMenking avatar BenMenking commented on July 26, 2024

I've made those changes in branch better-error-handling so you can test them out. Didn't go as far as adding in exceptions right now.

from routeros-api.

scottchiefbaker avatar scottchiefbaker commented on July 26, 2024

I don't think you pushed that branch. I'm not seeing that on my local repo, or on Github.

from routeros-api.

BenMenking avatar BenMenking commented on July 26, 2024

It's there now. Had to find my laptop :)

from routeros-api.

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.