Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyslogUdpHandler - Call to socket_sendto() throws a Fatal error: uncaught exception if a wrong / unreachable IP is given. #1085

Closed
mrtariqkhan opened this issue Nov 22, 2017 · 3 comments

Comments

@mrtariqkhan
Copy link

mrtariqkhan commented Nov 22, 2017

$handler = new SyslogUdpHandler('192.168.225.3668', 514, LOG_USER, env('LOG_LEVEL', 'DEBUG'));
$handler->setFormatter($lineformatter);
$monolog->pushHandler($handler);

results in

2017/11/22 13:41:45 [error] 1612#1612: *177 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught ErrorException: socket_sendto(): Host lookup failed [-10001]: Unknown host in /home/project/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php:47

Stack trace:
-0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'socket_sendto()...', '/home/...', 47, Array)

-1 vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php(47): socket_sendto(Resource id #4, '<11>1 2017-11-2...', 274, 0, '192.168.225.564', 514)

-2 vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php(31): Monolog\Handler\SyslogUdp\UdpSocket->send('<11>1 2017-11-2...')

-3 vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php(51): Monolog\Handler\SyslogUdp\UdpSocket->write('2017-11-22T13:4...', '<11>1 2017-11-2...')


Is there a reason its this way and not caught gracefully?

@mrtariqkhan mrtariqkhan changed the title SyslogUdpHandler - Call to socket_sendto() throws an Fatal error: uncaught exception if a wrong / unreachable IP is given. SyslogUdpHandler - Call to socket_sendto() throws a Fatal error: uncaught exception if a wrong / unreachable IP is given. Nov 22, 2017
@tomzx
Copy link
Contributor

tomzx commented Jan 5, 2018

192.168.225.3668 is not a valid ip address.

@mrtariqkhan
Copy link
Author

indeed it is, the problem is it throws out an unhandeled fatal exception. Which is an issue if the supplied IP or domain name goes down for some reason. In my case its the rsyslogd server which went down and took the whole application down with it.

@Seldaek
Copy link
Owner

Seldaek commented Jun 17, 2018

You should use a WhatFailureGroupHandler if you want to swallow errors in handlers.

@Seldaek Seldaek closed this as completed Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants