Seldaek/monolog · error · RuntimeException

The UdpSocket to {}:{} could not be opened via socket_create

Error message

The UdpSocket to {}:{} could not be opened via socket_create

What it means

Error "The UdpSocket to {}:{} could not be opened via socket_create" thrown in Seldaek/monolog.

Source

Thrown at src/Monolog/Handler/SyslogUdp/UdpSocket.php:63

    {
        if (null !== $this->socket) {
            return $this->socket;
        }

        $domain = AF_INET;
        $protocol = SOL_UDP;
        // Check if we are using unix sockets.
        if ($this->port === 0) {
            $domain = AF_UNIX;
            $protocol = IPPROTO_IP;
        }

        $socket = socket_create($domain, SOCK_DGRAM, $protocol);
        if ($socket instanceof Socket) {
            return $this->socket = $socket;
        }

        throw new \RuntimeException('The UdpSocket to '.$this->ip.':'.$this->port.' could not be opened via socket_create');
    }

    protected function send(string $chunk): void
    {
        socket_sendto($this->getSocket(), $chunk, \strlen($chunk), $flags = 0, $this->ip, $this->port);
    }

    protected function assembleMessage(string $line, string $header): string
    {
        $chunkSize = static::DATAGRAM_MAX_LENGTH - \strlen($header);

        return $header . Utils::substr($line, 0, $chunkSize);
    }
}

View on GitHub (pinned to 57eb102834)

When it happens

Trigger: Thrown at src/Monolog/Handler/SyslogUdp/UdpSocket.php:63 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Seldaek/monolog@57eb102834 (2026-08-17). Data as JSON: /api/errors/523107640f182c9f. Report an issue: GitHub.