Tibber.SDK.NET icon indicating copy to clipboard operation
Tibber.SDK.NET copied to clipboard

The WebSocket is in an invalid state ('CloseReceived')

Open janwiesemann opened this issue 3 years ago • 3 comments

I just wrote a small app which received live measurements and then pushes them into an influx database. Sadly, I've been experiencing some issues.

I'm running this in a Proxmox LXC-Container using netcoreapp3.1. This issues seams to occur, when the LXC is getting backed up.

The project and source is available at: https://github.com/janwiesemann/tibberToInfluxDB. Not all functions use Tibber.SDK.NET, since it started without this library.

You can find the log below.

Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]: home 0000000-11111-2222-3333-44444444444 subscription 1: no data received during last 62,524 ms; re-initialize data stream
Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]: subscribe to 0000000-11111-2222-3333-44444444444
Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]: web socket operation failed System.Net.WebSockets.WebSocketException (0x80004005): The WebSocket is in an invalid state ('CloseReceived') for this operation. Valid states are: 'Open, CloseSent'
                                                              at System.Net.WebSockets.WebSocketValidate.ThrowIfInvalidState(WebSocketState currentState, Boolean isDisposed, WebSocketState[] validStates)
                                                              at System.Net.WebSockets.ManagedWebSocket.ReceiveAsync(ArraySegment`1 buffer, CancellationToken cancellationToken)
                                                           --- End of stack trace from previous location where exception was thrown ---
                                                              at Tibber.Sdk.RealTimeMeasurementListener.StartListening()
Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]: System.Net.WebSockets.WebSocketException (0x80004005): The WebSocket is in an invalid state ('CloseReceived') for this operation. Valid states are: 'Open, CloseSent'
Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]:    at System.Net.WebSockets.WebSocketValidate.ThrowIfInvalidState(WebSocketState currentState, Boolean isDisposed, WebSocketState[] validStates)
Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]:    at System.Net.WebSockets.ManagedWebSocket.ReceiveAsync(ArraySegment`1 buffer, CancellationToken cancellationToken)
Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]: --- End of stack trace from previous location where exception was thrown ---
Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]:    at Tibber.Sdk.RealTimeMeasurementListener.StartListening()
Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]: listener disposal started
Dec 16 11:15:38 MetricCollector tibberToInfluxDB[1815205]: listener disposal finished

Note: GUIDs changed!

janwiesemann avatar Dec 16 '22 16:12 janwiesemann

@janwiesemann did you figure this one out?

toini avatar Feb 22 '23 08:02 toini

@toini not really, I haven't had the time to do so. I've worked around this issue by hard crashing my application and using a systemd service to automatically restart it a few minutes later.

janwiesemann avatar Feb 23 '23 23:02 janwiesemann

@janwiesemann I have a vague memory i saw something similar before and incorrectly interpreted some of the log rows indicating failure while it had actually been intended behaviour. However im not sure if this is a similar case.

Would you have any instructions on how i could reproduce this myself? What lead this situation?

toini avatar Mar 02 '23 14:03 toini