Comments (3)
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.
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.
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)
- Counter64 Values Can Exceed the PHP Max Int Value HOT 2
- Authentication was requested, but the received header has none specified. HOT 11
- Do I need to close SnmpClient? HOT 7
- No message received from host. HOT 7
- SnmpWalk method not working HOT 3
- Certain return types do not get interpeted correctly in walks HOT 7
- send string value HOT 1
- reactPHP HOT 4
- SNMP Server Component HOT 1
- Equivalent for snmp_bulk_walk HOT 10
- What is the purpose of 1.3.6.1.2.1 HOT 3
- Reason for spread operator HOT 4
- How used other MIBs HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from snmp.