AlexxIT / SSHCommand

Run any SSH command on remote server from Home Assistant service call
https://github.com/AlexxIT/Blog
MIT License
89 stars 7 forks source link

Running SSH Service Causes HA Restart #19

Closed PablaV closed 5 months ago

PablaV commented 1 year ago

Whenever a SSH command is sent, HA restarts. This started around 2023.7 and I am seeing the following in the logs. Currently running 2023.7.1. Nothing more to report, this happens regardless of what SSH command is sent.


2023-07-28 09:47:47.051 INFO (MainThread) [custom_components.ssh_command] b''
2023-07-28 09:47:47.068 WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.master_bedroom is taking over 10 seconds
2023-07-28 09:47:47.093 WARNING (MainThread) [hass_nabucasa.iot] Connection closed: Cannot write to closing transport
2023-07-28 09:47:47.115 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 676, in ping
await self._send_frame(message, WSMsgType.PING)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 646, in _send_frame
self._write(header + mask + message)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 663, in _write
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport
2023-07-28 09:47:47.119 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 676, in ping
await self._send_frame(message, WSMsgType.PING)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 646, in _send_frame
self._write(header + mask + message)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 663, in _write
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport
2023-07-28 09:47:47.121 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 676, in ping
await self._send_frame(message, WSMsgType.PING)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 646, in _send_frame
self._write(header + mask + message)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 663, in _write
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport
2023-07-28 09:47:47.124 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 676, in ping
await self._send_frame(message, WSMsgType.PING)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 646, in _send_frame
self._write(header + mask + message)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 663, in _write
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport
2023-07-28 09:47:47.127 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 676, in ping
await self._send_frame(message, WSMsgType.PING)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 646, in _send_frame
self._write(header + mask + message)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 663, in _write
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport
2023-07-28 09:47:47.130 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 676, in ping
await self._send_frame(message, WSMsgType.PING)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 646, in _send_frame
self._write(header + mask + message)
File "/usr/local/lib/python3.11/site-packages/aiohttp/http_websocket.py", line 663, in _write
raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport```
AlexxIT commented 11 months ago

What command are you running?

filippo196302 commented 11 months ago

I confirm restart HA with ssh command. I tested with "sudo reboot" and "sudo shutdown now"

HA 2023.10

AlexxIT commented 11 months ago

You reboot Hass server and wonder why Hass reboots with it?

PablaV commented 11 months ago

I was running a script that took over 60 seconds to complete and according to HA docs you can't run commands that take longer than 60 seconds