{"record":{"id":"b4c39f21af7ab0c4","repo":"Seldaek/monolog","slug":"could-not-write-to-socket","errorCode":null,"errorMessage":"Could not write to socket","messagePattern":"Could not write to socket","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/SocketHandler.php","lineNumber":395,"sourceCode":"    {\n        if (null !== $this->chunkSize && false === $this->streamSetChunkSize()) {\n            throw new \\UnexpectedValueException(\"Failed setting chunk size with stream_set_chunk_size()\");\n        }\n    }\n\n    private function writeToSocket(string $data): void\n    {\n        $length = \\strlen($data);\n        $sent = 0;\n        $this->lastSentBytes = $sent;\n        while ($this->isConnected() && $sent < $length) {\n            if (0 === $sent) {\n                $chunk = $this->fwrite($data);\n            } else {\n                $chunk = $this->fwrite(substr($data, $sent));\n            }\n            if ($chunk === false) {\n                throw new \\RuntimeException(\"Could not write to socket\");\n            }\n            $sent += $chunk;\n            $socketInfo = $this->streamGetMetadata();\n            if (\\is_array($socketInfo) && (bool) $socketInfo['timed_out']) {\n                throw new \\RuntimeException(\"Write timed-out\");\n            }\n\n            if ($this->writingIsTimedOut($sent)) {\n                throw new \\RuntimeException(\"Write timed-out, no data sent for `{$this->writingTimeout}` seconds, probably we got disconnected (sent $sent of $length)\");\n            }\n        }\n        if (!$this->isConnected() && $sent < $length) {\n            throw new \\RuntimeException(\"End-of-file reached, probably we got disconnected (sent $sent of $length)\");\n        }\n    }\n\n    private function writingIsTimedOut(int $sent): bool\n    {","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/SocketHandler.php#L377-L413","documentation":"Error \"Could not write to socket\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/SocketHandler.php:395 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57eb1028342134e701e77c617565d51b6e5a2a53","analyzedAt":"2026-08-17T02:36:30.259Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}