GithubHelp home page GithubHelp logo

Comments (3)

Guyverix avatar Guyverix commented on June 2, 2024

Continuing to poke at this, and reverted back to your original code, it looks like I was making matters worse due to my inexperience. I do still get the fatal errors, but it is returning the exception data in an almost usable way. I am just unsure what I can do about the Fatal error that is being spewed back..

/usr/bin/php8.2 ./blah.php 
PHP Fatal error:  Uncaught FreeDSx\Socket\Exception\ConnectionException: Unable to connect to 192.168.15.589: php_network_getaddresses: getaddrinfo for 192.168.15.589 failed: Name or service not known in /opt/nmsApi/vendor/freedsx/socket/src/FreeDSx/Socket/Socket.php:236
Stack trace:
#0 /opt/nmsApi/vendor/freedsx/socket/src/FreeDSx/Socket/Socket.php(269): FreeDSx\Socket\Socket->connect()
#1 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ProtocolTrait.php(145): FreeDSx\Socket\Socket::create()
#2 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php(150): FreeDSx\Snmp\Protocol\ClientProtocolHandler->socket()
#3 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php(122): FreeDSx\Snmp\Protocol\ClientProtocolHandler->sendRequestGetResponse()
#4 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(233): FreeDSx\Snmp\Protocol\ClientProtocolHandler->handle()
#5 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(113): FreeDSx\Snmp\SnmpClient->send()
#6 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(126): FreeDSx\Snmp\SnmpClient->get()
#7 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(139): FreeDSx\Snmp\SnmpClient->getOid()
#8 /opt/nmsApi/testing/freedsx/blah.php(14): FreeDSx\Snmp\SnmpClient->getValue()
#9 {main}

Next FreeDSx\Snmp\Exception\ConnectionException: Unable to connect to 192.168.15.589: php_network_getaddresses: getaddrinfo for 192.168.15.589 failed: Name or service not known in /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ProtocolTrait.php:157
Stack trace:
#0 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php(150): FreeDSx\Snmp\Protocol\ClientProtocolHandler->socket()
#1 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ClientProtocolHandler.php(122): FreeDSx\Snmp\Protocol\ClientProtocolHandler->sendRequestGetResponse()
#2 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(233): FreeDSx\Snmp\Protocol\ClientProtocolHandler->handle()
#3 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(113): FreeDSx\Snmp\SnmpClient->send()
#4 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(126): FreeDSx\Snmp\SnmpClient->get()
#5 /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/SnmpClient.php(139): FreeDSx\Snmp\SnmpClient->getOid()
#6 /opt/nmsApi/testing/freedsx/blah.php(14): FreeDSx\Snmp\SnmpClient->getValue()
#7 {main}
  thrown in /opt/nmsApi/vendor/freedsx/snmp/src/FreeDSx/Snmp/Protocol/ProtocolTrait.php on line 157

from snmp.

ChadSikorra avatar ChadSikorra commented on June 2, 2024

Hi @Guyverix! Are you saying that you want to catch the ConnectionException being thrown and do something with it? Or that you're not expecting it to give that message? 🤔 Only asking as you did mention giving it invalid data.

from snmp.

Guyverix avatar Guyverix commented on June 2, 2024

I am attempting to catch the exception. Both of the exception catches I expected to catch the problem spit the fatal error. I have tried many other catches as well, but am guessing one of these two would be the most likely to work..

    catch (FreeDSx\Socket\Exception\ConnectionException $e) {
    catch (ConnectionException $e) {

I am 100% certain that this is due to my lack of experience with try catch. I figured after 3 days of trying it would just be easier to ask what I was doing wrong :)

I am deliberately giving invalid data to write error correction in my application. Invalid IP addresses, wrong community strings, impossible versions, etc.

from snmp.

Related Issues (14)

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.