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

Closed
opened 2026-03-04 02:15:03 +03:00 by kerem · 3 comments
Owner

Originally created by @mrtariqkhan on GitHub (Nov 22, 2017).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1085

$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?

Originally created by @mrtariqkhan on GitHub (Nov 22, 2017). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1085 $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?
kerem closed this issue 2026-03-04 02:15:03 +03:00
Author
Owner

@tomzx commented on GitHub (Jan 5, 2018):

192.168.225.3668 is not a valid ip address.

<!-- gh-comment-id:355637454 --> @tomzx commented on GitHub (Jan 5, 2018): `192.168.225.3668` is not a valid ip address.
Author
Owner

@mrtariqkhan commented on GitHub (Jan 29, 2018):

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.

<!-- gh-comment-id:361340254 --> @mrtariqkhan commented on GitHub (Jan 29, 2018): 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.
Author
Owner

@Seldaek commented on GitHub (Jun 17, 2018):

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

<!-- gh-comment-id:397883631 --> @Seldaek commented on GitHub (Jun 17, 2018): You should use a WhatFailureGroupHandler if you want to swallow errors in handlers.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#440
No description provided.