dannyyy / electrolux_mqtt

Electrolux to MQTT
GNU General Public License v3.0
6 stars 0 forks source link

Background service failed #1

Open norbeyandresg opened 1 month ago

norbeyandresg commented 1 month ago

Running the container with docker compose I'm getting the following error

[03:39:31 INF] Application Shutdown
[03:39:32 INF] Application Start
[03:39:32 INF] Connect to MQTT server
[03:39:33 INF] Connected to MQTT server mosquitto on port 1883
[03:39:35 ERR] BackgroundService failed
System.NullReferenceException: Object reference not set to an instance of an object.
   at Electrolux.Infrastructure.Repository.ElectroluxRepository.EnsureLoginAsync(CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/Repository/ElectroluxRepository.cs:line 102
   at Electrolux.Infrastructure.Repository.ElectroluxRepository.GetAppliances(CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/Repository/ElectroluxRepository.cs:line 35
   at Electrolux.Domain.UseCases.GetAppliances.ApplianceService.GetAppliancesAndPublishCapabilitiesAndStateAsync(CancellationToken cancellationToken) in /app/Electrolux/Domain/UseCases/GetAppliances/ApplianceService.cs:line 57
   at Electrolux.Application.Mqtt.MqttWorker.ExecuteAsync(CancellationToken cancellationToken) in /app/Electrolux/Application/Mqtt/MqttWorker.cs:line 35
   at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
[03:39:35 FTL] The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Electrolux.Infrastructure.Repository.ElectroluxRepository.EnsureLoginAsync(CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/Repository/ElectroluxRepository.cs:line 102
   at Electrolux.Infrastructure.Repository.ElectroluxRepository.GetAppliances(CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/Repository/ElectroluxRepository.cs:line 35
   at Electrolux.Domain.UseCases.GetAppliances.ApplianceService.GetAppliancesAndPublishCapabilitiesAndStateAsync(CancellationToken cancellationToken) in /app/Electrolux/Domain/UseCases/GetAppliances/ApplianceService.cs:line 57
   at Electrolux.Application.Mqtt.MqttWorker.ExecuteAsync(CancellationToken cancellationToken) in /app/Electrolux/Application/Mqtt/MqttWorker.cs:line 35
   at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)

This is my docker compose file. I have another container running with mosquitto as a MQTT server and already connect it to my Home Assistant container.


version: '3.8'

services:
  electrolux-mqtt:
    image: dannyyy/electrolux-mqtt:2.0.1
    container_name: electrolux-mqtt
    environment:
      - MQTT__HOST=mosquitto
      - MQTT__PORT=1883                              # (Default 8883)
      - MQTT__USETLS=false                          # (Default true)
      # - MQTT__TLSSHA256FINGERPRINT=<SHA256>            # If empty the certificate must be signed by a trusted CA
      # - MQTT__TRUSTALLCERTIFICATES=<TRUST-ALL>         # If true every certificate will be considered as valid, even revoked and expired. (Default false)
      # - MQTT__USERNAME=<MQTT-USERNAME>
      # - MQTT__PASSWORD=<MQTT-PASSWORD>
      # - MQTT__TOPICPREFIX=<TOPIC-PREFIX-WITH-TRAILING-SLASH>  # Empty or with trailing slash e.g. "smarthome/electrolux/" (Default "")
      # - MQTT__STATUSUPDATEINTERVAL=<UPDATE-INTERAL-IN-S>      # Reports devices, capabilities, and state (Default 30)
      - ELECTROLUX__EMAIL=myemail@gmail.com
      - ELECTROLUX__PASSWORD=securepass
    restart: unless-stopped
    networks:
      - nginx_default

networks:
  nginx_default:
    external: true
Kirbo commented 1 month ago

Same here. Everything worked fine since 14th of June and now all the sudden with 0 modifications/updates/nothing whatsoever, it just stopped working..

Here's the container log from Portainer:

[11:24:27 INF] Application Start
[11:24:27 INF] Connect to MQTT server
[11:24:27 INF] Connected to MQTT server 192.168.1.12 on port 1883
[11:24:30 ERR] BackgroundService failed
System.Text.Json.JsonException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo, ReadStack& state)
   at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
   at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore[T](HttpContent content, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken)
   at Electrolux.Infrastructure.ApiClients.Electrolux.ElectroluxApiClient.GetAppliances(String accessToken, CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/ApiClients/Electrolux/ElectroluxApiClient.cs:line 103
   at Electrolux.Infrastructure.Repository.ElectroluxRepository.GetAppliances(CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/Repository/ElectroluxRepository.cs:line 37
   at Electrolux.Domain.UseCases.GetAppliances.ApplianceService.GetAppliancesAndPublishCapabilitiesAndStateAsync(CancellationToken cancellationToken) in /app/Electrolux/Domain/UseCases/GetAppliances/ApplianceService.cs:line 57
   at Electrolux.Application.Mqtt.MqttWorker.ExecuteAsync(CancellationToken cancellationToken) in /app/Electrolux/Application/Mqtt/MqttWorker.cs:line 35
   at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
[11:24:30 FTL] The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted.
System.Text.Json.JsonException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo, ReadStack& state)
   at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
   at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore[T](HttpContent content, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken)
   at Electrolux.Infrastructure.ApiClients.Electrolux.ElectroluxApiClient.GetAppliances(String accessToken, CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/ApiClients/Electrolux/ElectroluxApiClient.cs:line 103
   at Electrolux.Infrastructure.Repository.ElectroluxRepository.GetAppliances(CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/Repository/ElectroluxRepository.cs:line 37
   at Electrolux.Domain.UseCases.GetAppliances.ApplianceService.GetAppliancesAndPublishCapabilitiesAndStateAsync(CancellationToken cancellationToken) in /app/Electrolux/Domain/UseCases/GetAppliances/ApplianceService.cs:line 57
   at Electrolux.Application.Mqtt.MqttWorker.ExecuteAsync(CancellationToken cancellationToken) in /app/Electrolux/Application/Mqtt/MqttWorker.cs:line 35
   at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
[11:24:30 INF] Application Shutdown
Kirbo commented 1 month ago

Same here. Everything worked fine since 14th of June and now all the sudden with 0 modifications/updates/nothing whatsoever, it just stopped working..

Here's the container log from Portainer:

[11:24:27 INF] Application Start
[11:24:27 INF] Connect to MQTT server
[11:24:27 INF] Connected to MQTT server 192.168.1.12 on port 1883
[11:24:30 ERR] BackgroundService failed
System.Text.Json.JsonException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo, ReadStack& state)
   at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
   at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore[T](HttpContent content, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken)
   at Electrolux.Infrastructure.ApiClients.Electrolux.ElectroluxApiClient.GetAppliances(String accessToken, CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/ApiClients/Electrolux/ElectroluxApiClient.cs:line 103
   at Electrolux.Infrastructure.Repository.ElectroluxRepository.GetAppliances(CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/Repository/ElectroluxRepository.cs:line 37
   at Electrolux.Domain.UseCases.GetAppliances.ApplianceService.GetAppliancesAndPublishCapabilitiesAndStateAsync(CancellationToken cancellationToken) in /app/Electrolux/Domain/UseCases/GetAppliances/ApplianceService.cs:line 57
   at Electrolux.Application.Mqtt.MqttWorker.ExecuteAsync(CancellationToken cancellationToken) in /app/Electrolux/Application/Mqtt/MqttWorker.cs:line 35
   at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
[11:24:30 FTL] The HostOptions.BackgroundServiceExceptionBehavior is configured to StopHost. A BackgroundService has thrown an unhandled exception, and the IHost instance is stopping. To avoid this behavior, configure this to Ignore; however the BackgroundService will not be restarted.
System.Text.Json.JsonException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
 ---> System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   --- End of inner exception stack trace ---
   at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo, ReadStack& state)
   at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
   at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore[T](HttpContent content, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken)
   at Electrolux.Infrastructure.ApiClients.Electrolux.ElectroluxApiClient.GetAppliances(String accessToken, CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/ApiClients/Electrolux/ElectroluxApiClient.cs:line 103
   at Electrolux.Infrastructure.Repository.ElectroluxRepository.GetAppliances(CancellationToken cancellationToken) in /app/Electrolux/Infrastructure/Repository/ElectroluxRepository.cs:line 37
   at Electrolux.Domain.UseCases.GetAppliances.ApplianceService.GetAppliancesAndPublishCapabilitiesAndStateAsync(CancellationToken cancellationToken) in /app/Electrolux/Domain/UseCases/GetAppliances/ApplianceService.cs:line 57
   at Electrolux.Application.Mqtt.MqttWorker.ExecuteAsync(CancellationToken cancellationToken) in /app/Electrolux/Application/Mqtt/MqttWorker.cs:line 35
   at Microsoft.Extensions.Hosting.Internal.Host.TryExecuteBackgroundServiceAsync(BackgroundService backgroundService)
[11:24:30 INF] Application Shutdown

For me it started to work again, with 0 changes anywhere whatsoever 😅 Might have been an issue on the API?