Sometimes mqtt commands just don't work

I think it's audio related. The jist of it is I have headphones and speakers that I try to switch between using a zigbee button, but sometimes until I restart hassagent this won't work at all I think something is crashing and not recovering properly. Here's the -only- logs during this time
2025-01-24 17:24:46.891 +02:00 [INF] [MEDIA] New state: Paused
2025-01-24 17:24:54.969 +02:00 [INF] [MEDIA] New state: Playing
2025-01-24 17:28:57.860 +02:00 [INF] [MEDIA] New state: Paused
2025-01-24 18:27:53.691 +02:00 [WRN] [MEDIA] No MediaSession active
2025-01-24 18:27:54.797 +02:00 [ERR] [NET] [ConnectionRefused] No connection could be made because the target machine actively refused it.
2025-01-24 18:28:40.049 +02:00 [INF] [HASS_API] Server recovered from failed state
2025-01-24 18:59:45.782 +02:00 [FTL] [PROGRAM] FirstChanceException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
at System.Net.Http.HttpConnection.<CheckUsabilityOnScavenge>g__ReadAheadWithZeroByteReadAsync|45_0()
2025-01-24 17:24:46.891 +02:00 [INF] [MEDIA] New state: Paused
2025-01-24 17:24:54.969 +02:00 [INF] [MEDIA] New state: Playing
2025-01-24 17:28:57.860 +02:00 [INF] [MEDIA] New state: Paused
2025-01-24 18:27:53.691 +02:00 [WRN] [MEDIA] No MediaSession active
2025-01-24 18:27:54.797 +02:00 [ERR] [NET] [ConnectionRefused] No connection could be made because the target machine actively refused it.
2025-01-24 18:28:40.049 +02:00 [INF] [HASS_API] Server recovered from failed state
2025-01-24 18:59:45.782 +02:00 [FTL] [PROGRAM] FirstChanceException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
at System.Net.Http.HttpConnection.<CheckUsabilityOnScavenge>g__ReadAheadWithZeroByteReadAsync|45_0()
After it's just other "new state playing" or paused or etc
6 Replies
barrelltitor
barrelltitorOP5d ago
Earlier it worked just fine though
2025-01-24 16:21:55.070 +02:00 [DBG] [AUDIOMGR] device 'Speakers (Focusrite USB Audio)' activated
2025-01-24 16:22:00.095 +02:00 [DBG] [AUDIOMGR] device 'Headphones (2- Logitech G733 Gaming Headset)' activated
2025-01-24 16:22:02.005 +02:00 [DBG] [AUDIOMGR] device 'Speakers (Focusrite USB Audio)' activated
2025-01-24 16:22:03.710 +02:00 [DBG] [AUDIOMGR] device 'Headphones (2- Logitech G733 Gaming Headset)' activated
2025-01-24 16:22:05.527 +02:00 [DBG] [AUDIOMGR] device 'Speakers (Focusrite USB Audio)' activated
2025-01-24 16:21:55.070 +02:00 [DBG] [AUDIOMGR] device 'Speakers (Focusrite USB Audio)' activated
2025-01-24 16:22:00.095 +02:00 [DBG] [AUDIOMGR] device 'Headphones (2- Logitech G733 Gaming Headset)' activated
2025-01-24 16:22:02.005 +02:00 [DBG] [AUDIOMGR] device 'Speakers (Focusrite USB Audio)' activated
2025-01-24 16:22:03.710 +02:00 [DBG] [AUDIOMGR] device 'Headphones (2- Logitech G733 Gaming Headset)' activated
2025-01-24 16:22:05.527 +02:00 [DBG] [AUDIOMGR] device 'Speakers (Focusrite USB Audio)' activated
HASS.Agent Helper
Help us Help Others!
To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution
From An unknown user
HASS.Agent Helper
Help us Help You!
Please don't delete messages or posts because it makes it impossible to understand what happened. If you don't want your messages to be seen then don't post here. Please provide us with the version number of your app.
You can find it by clicking the ? at the bottom of the main page and checking under the logo that shows.
We will help as soon as possible. While you're waiting you can try the following:
- Checkout the documentation. - Search here in discord for previously solved similar issues.
HASS.Agent Helper
@Amadeo
barrelltitor
barrelltitorOP5d ago
I'm running 2.1.1-beta2, upgrading to beta 3 to see if there's any difference
Amadeo
Amadeo3d ago
I think it's audio related.
how so?
but sometimes until I restart hassagent this won't work at all
do other sensors/commands still work and only this one fails? the error "[ERR] [NET] [ConnectionRefused] No connection could be made because the target machine actively refused it." suggests that there is an issue with connection (I guess mqtt)

Did you find this page helpful?