More debugging trying to catch websocket connect errors

This commit is contained in:
Deon George 2022-06-22 10:39:45 +10:00
parent b69220b1ce
commit 1e5281de29
1 changed files with 7 additions and 3 deletions

View File

@ -89,8 +89,8 @@ class SocketMode extends API
// initiate the websocket connection
// write PHPWS things to the existing logger
$this->websocket = new WebSocket($response['url'].($this->debug_reconnect ? '&debug_reconnects=true' : ''),$this->loop,$this->logger);
$this->websocket->on('message', function ($message) {
Log::debug(sprintf('%s:- Calling onMessage ...',self::LOGKEY),['m'=>__METHOD__]);
$this->websocket->on('message', function ($message) use ($response) {
Log::debug(sprintf('%s:- Calling onMessage ...',self::LOGKEY),['m'=>__METHOD__,'payload'=>serialize($response),'message'=>serialize($message)]);
$this->onMessage($message);
});
@ -169,7 +169,11 @@ class SocketMode extends API
Log::debug(sprintf('%s:+ Start',self::LOGKEY),['m'=>__METHOD__]);
// parse the message and get the event name
$payload = Payload::fromJson($message->getData());
try {
$payload = Payload::fromJson($message->getData());
} catch (\UnexpectedValueException $e) {
Log::error(sprintf('%s:! ERROR in json payload in onMessage',self::LOGKEY),['message'=>serialize($message)]);
}
$emitted = FALSE;
if (isset($payload['type'])) {