smartmeter2mqtt icon indicating copy to clipboard operation
smartmeter2mqtt copied to clipboard

Auto reconnect to socket

Open zuidwijk opened this issue 3 years ago • 5 comments

I've been playing with your smartmeter2mqtt and found an issue:

If the connection to a network device get lost, it won't reconnect.

version: "3.7"

services:
  smartmeter:
    image: svrooij/smartmeter:1.6.0-beta.5
    restart: unless-stopped
    ports: # Depending on your situation you'll need to expose some ports
      - 3000:3000
      - 3010:3010
      - 3020:3020
    environment:
      - TZ=Europe/Amsterdam
      - SMARTMETER_socket=192.168.0.10:23
      - SMARTMETER_web-server=3000
      - SMARTMETER_tcp-server=3010
      - SMARTMETER_raw-tcp-server=3020

When I disconnect and reconnect my ethernet reader, it won't reconnect.

zuidwijk avatar Feb 25 '21 10:02 zuidwijk

At that point the app will exit with an error code. Then you can use docker to just restart the container (by adding restart: on-failure)

svrooij avatar Feb 25 '21 12:02 svrooij

Nope, the container keeps running without any error.

zuidwijk avatar Feb 25 '21 13:02 zuidwijk

It had the code in the program, but I overlooked the documentation. By default a socket has no timeout....

Now it will exit as expected when there isn't any data for 60 seconds.

svrooij avatar Feb 25 '21 15:02 svrooij

So I can change

socket.setTimeout(0);

To (30000 milliseconds)

socket.setTimeout(30000);

zuidwijk avatar Feb 25 '21 16:02 zuidwijk

:tada: This issue has been resolved in version 1.7.0-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Feb 26 '21 18:02 github-actions[bot]