From 7fbfbc602d626d75e0bd264db22bdf3bfac3b2a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cevallos?= Date: Wed, 16 Mar 2016 10:50:55 +0100 Subject: [PATCH] added timeout to send the information and not get long waiting time --- src/M6Web/Component/Statsd/Client.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/M6Web/Component/Statsd/Client.php b/src/M6Web/Component/Statsd/Client.php index 192342f..ed176cb 100644 --- a/src/M6Web/Component/Statsd/Client.php +++ b/src/M6Web/Component/Statsd/Client.php @@ -34,6 +34,12 @@ class Client */ private $serverKeys = array(); + /** + * Timeout to send the data + * @const integer + */ + const TIMEOUT = 2; + /** * contructeur * @param array $servers les serveurs @@ -320,6 +326,7 @@ public function writeDatas($server, $datas) } $s = $this->getServers()[$server]; $fp = fsockopen($s['address'], $s['port']); + stream_set_timeout($fp, self::TIMEOUT); if ($fp !== false) { foreach ($datas as $value) { // write packets