declension / squeeze-alexa

Squeezebox integration for Amazon Alexa
GNU General Public License v3.0
59 stars 20 forks source link

MQTT: reconnect if cached client connection is dropped #110

Open declension opened 6 years ago

declension commented 6 years ago

If a cached MQTT transport's client somehow disconnects, you get this:

Reusing cached instance Squeezebox server over MQTT to client to aorobo3koaq53.iot.eu-west-1.amazonaws.com:8883Disconnected from client to aorobo3koaq53.iot.eu-west-1.amazonaws.com:8883

Then

Traceback (most recent call last):
File "/var/task/handler.py", line 47, in lambda_handler
return sqa.handle(event, context)
File "/var/task/squeezealexa/main.py", line 65, in handle
return super(SqueezeAlexa, self).handle(event, context)
File "/var/task/squeezealexa/alexa/handlers.py", line 49, in handle
return self.on_intent(request, session)
File "/var/task/squeezealexa/main.py", line 90, in on_intent
return intent_handler(self, intent, session, pid=pid)
File "/var/task/squeezealexa/main.py", line 106, in on_pause
self._server.pause(player_id=pid)
File "/var/task/squeezealexa/squeezebox/server.py", line 364, in pause
self.player_request("pause 1", player_id=player_id)
File "/var/task/squeezealexa/squeezebox/server.py", line 259, in player_request
raw=raw, wait=wait)[0]
File "/var/task/squeezealexa/squeezebox/server.py", line 171, in _request
cmd=first_word, transport=self.transport))
squeezealexa.squeezebox.server.SqueezeboxException: Can't do 'pause', MQTT to client to **********.iot.eu-west-1.amazonaws.com:8883 is not connected

See #109 for the (now fixed) problem reporting this nicely.