declension / squeeze-alexa

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

mqtt-squeeze: survive telnet connection drops / LMS restarts #57

Open declension opened 6 years ago

declension commented 6 years ago

In mqttsqueeze, currently we get an EOFError if the persistent CLI connection is interrupted. Better if it wrapped this and restarted somehow (probably likewise with the MQTT connection though the library hopefully handles this itself a bit)

Example Logs

  File "./main.py", line 74, in <module>                                                                                                      
    client.loop_forever(retry_first_connection=True)                                                                                          
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/paho/mqtt/client.py", line 1481, in loop_forever                        
    rc = self.loop(timeout, max_packets)                                                                                                      
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/paho/mqtt/client.py", line 1003, in loop                                
    rc = self.loop_read(max_packets)                                                                                                          
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/paho/mqtt/client.py", line 1284, in loop_read                           
    rc = self._packet_read()                                                                                                                  
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/paho/mqtt/client.py", line 1849, in _packet_read                        
    rc = self._packet_handle()                                                                                                                
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/paho/mqtt/client.py", line 2305, in _packet_handle                      
    return self._handle_publish()                                                                                                             
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/paho/mqtt/client.py", line 2504, in _handle_publish                     
    self._handle_on_message(message)                                                                                                          
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/paho/mqtt/client.py", line 2647, in _handle_on_message                  
    self.on_message(self, self._userdata, message)                                                                                            
  File "./main.py", line 40, in on_message                                                                                                    
    resp_lines.append(telnet.read_until(b'\n').strip())                                                                                       
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/telnetlib.py", line 327, in read_until                                                
    return self.read_very_lazy()                                                                                                              
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/telnetlib.py", line 403, in read_very_lazy                                            
    raise EOFError('telnet connection closed')                                                                                                
EOFError: telnet connection closed                                                                                                            
Disconnecting broker on *****.*****.amazonaws.com:8883                                                                        
Underlying socket connection gone (_ssl.c:1770)
declension commented 6 years ago

To a large extent this is solved by the service wrappers, e.g. Upstart

declension commented 5 years ago

System wrapper scripts documented and working for systemd and Upstart, and won't get better than this, so closing

declension commented 5 years ago

No, this is still a problem, as the exception is actually caught within the app, e.g. after an LMS restart:

2019-03-10T00:16:12+0000 [ERROR  ] Caught exception in on_message: telnet connection closed