From e7b7dd0da8bda7da211e3559019bbf6405a73062 Mon Sep 17 00:00:00 2001 From: Rello Date: Sun, 9 Dec 2018 20:53:55 +0100 Subject: [PATCH] SONOS socket backend error handling #348 --- lib/Controller/SonosController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Controller/SonosController.php b/lib/Controller/SonosController.php index 27122753..8527db6c 100644 --- a/lib/Controller/SonosController.php +++ b/lib/Controller/SonosController.php @@ -185,7 +185,17 @@ public function getDeviceList() private function discoverDevices() { $port = 1900; - $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + try { + //$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + $sock = socket_create(AF_INET, SOCK_DGRAM, 21); + } catch (\Exception $e) { + $this->logger->error('SONOS discovery not possible; no socket setup on webserver; check Audio Player wiki', array('app' => 'audioplayer')); + return array(); + } + if (!$sock) { + $this->logger->error('SONOS discovery not possible; connection issue; check Audio Player wiki', array('app' => 'audioplayer')); + return array(); + } $level = getprotobyname("ip"); socket_set_option($sock, $level, IP_MULTICAST_TTL, 2); $data = "M-SEARCH * HTTP/1.1\r\n";