IOT Link & Mosquitto Broker Addon = Socket error on client XXXXXXXX, disconnecting

I’m curious if anyone has figured out a way to get IOT Link for Windows to work with the Mosquitto Broker Addon reliably. IOT Link is able to connect and provide data; but then shortly after produces a socket error and reconnects again. I have another MQTT client (EventGhost) which connects to the MQTT Broker reliably. It seems like this issue is specific to IOT Link and the Home Assistant MQTT Broker Addon.

1593210514: New connection from 192.168.1.2 on port 1883.
1593210514: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210514: Client MQTTClient disconnected.
1593210514: New connection from 192.168.1.2 on port 1883.
1593210514: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210514: Socket error on client MQTTClient, disconnecting.
1593210518: New connection from 192.168.1.2 on port 1883.
1593210518: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210519: New connection from 192.168.1.2 on port 1883.
1593210519: Client MQTTClient already connected, closing old connection.
1593210519: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210580: Socket error on client MQTTClient, disconnecting.
1593210583: New connection from 192.168.1.2 on port 1883.
1593210583: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210583: Client MQTTClient disconnected.
1593210583: New connection from 192.168.1.2 on port 1883.
1593210583: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210585: Client MQTTClient disconnected.
1593210589: New connection from 192.168.1.2 on port 1883.
1593210589: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210590: Client MQTTClient disconnected.
1593210590: New connection from 192.168.1.2 on port 1883.
1593210590: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210590: Socket error on client MQTTClient, disconnecting.
1593210594: New connection from 192.168.1.2 on port 1883.
1593210594: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210594: Client MQTTClient disconnected.
1593210594: New connection from 192.168.1.2 on port 1883.
1593210594: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210655: Socket error on client MQTTClient, disconnecting.
1593210658: New connection from 192.168.1.2 on port 1883.
1593210658: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210658: Client MQTTClient disconnected.
1593210658: New connection from 192.168.1.2 on port 1883.
1593210658: New client connected from 192.168.1.2 as MQTTClient (p2, c1, k60, u'mkanet').
1593210661: Socket error on client MQTTClient, disconnecting.

Hi, did you find any solution to this?

@Jarpetnee, this issue is caused by IOT Link, not by HA’s MQTT broker. It looks like the developer for IOTLink finally abandon that project. The last time I saw him active on his IOTLink Discord server, he was busy playing a game on Twitch.

I finally had enough and decided to use Glances + Home Assistant REST sensors as an alternate solution. Glances offers much more information than IOT Link. It’s a bit of a PITA to configure all the REST sensors in Home Assistant; but, well worth it once its done. If you’re interested in going down this route, I can share my REST sensor configs from my Configuration.yaml. I even made a small script on my PC to take a screenshot every 15 seconds just like IOT Link; except with less resource consumption.

I still use HA’s MQTT broker to talk to Event Ghost without any issues

1 Like

Cheers @mkanet . Yeah after another hour of troubleshooting after seeing your post I also decided to give it the boot. Probably for the best considering the other issues with memory leaks and security.

Would definitely be interested in seeing your Glances REST sensor configs if you have the time. I wish I had gone with Glances first time round.

Did you intend to use IOT Link for remote commands? If so do you recommend any alternatives? The main thing I want to do is remote shutdown.

Also how did you go about deleting all the IOTL/MQTT entities?

Many thanks.

Sorry for the late response. Please download my configuration.yaml example below. You can use it as a reference.

I use MQTT Broker Addon for Home Assistant --> EventGhost to use remote control commands for my Windows server. You can do pretty much anything you want using EventGhost. I use the MQTT addon for EventGhost. Sorry, I can’t remember how I removed my old IOT Link entities. If I remember, I’ll post here.

You’ll need to install Glances on the PC you have/had IOT Link installed on. Then, start Glances with the command line for example:

glances -w

configuration.yaml

The result could look something like the below screenshot. All the data you see below comes from Glances instead of IOT Link. Good luck!

1 Like

I have the same problem

Could you post the configuration file here? The link is off

Please download it from the link below. You might want to download it soon so the link doesn’t break again. You would only need to modify it a little bit for your setup. All the hard part is already done. It includes all the sensors you would get in IOT-Link and more, Good luck. Let me know if you run into any issues.

configuration.yaml

If the link breaks… ty!

sensor:
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/uptime
    value_template: '{{ value_json | regex_replace(find="[\"]", replace="") | regex_replace(find="(?<=( (\d{1})|(\d{2})):\d{2}):\d{2}", replace=" hours") }}'
    name: Horizon Uptime
    verify_ssl: false
    timeout: 20
    scan_interval: 8
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/cpu
    name: Horizon CPU
    value_template: '{{ value_json.total | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 20
    scan_interval: 8
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/mem
    name: Horizon RAM
    value_template: '{{ value_json.percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 20
    scan_interval: 8
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/memswap
    name: Horizon Pagefile
    value_template: '{{ value_json.percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 20
    scan_interval: 8
  - platform: rest
    name: gpu
    resource: http://192.168.1.2:61208/api/3/gpu
    value_template: '{{ ( value_json ) }}'
    json_attributes:
      - name
      - mem
      - proc
      - temperature
    verify_ssl: false
    timeout: 20
    scan_interval: 8
  - platform: rest
    name: network
    resource: http://192.168.1.2:61208/api/3/network
    value_template: N/A
    json_attributes:
      - interface_name
      - time_since_update
      - cumulative_rx
      - rx
      - cumulative_tx
      - tx
      - cumulative_cx
      - cx
      - is_up
      - speed
    verify_ssl: false
    timeout: 20
    scan_interval: 8
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/fs
    name: Horizon C Drive Used
    value_template: '{{ value_json[0].percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 20
    scan_interval: 8
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/fs
    name: Horizon E Drive Used
    value_template: '{{ value_json[1].percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 20
    scan_interval: 8
  - platform: rest
    name: diskio_0
    resource: http://192.168.1.2:61208/api/3/diskio
    value_template: '{{ ( value_json[0] ) }}'
    json_attributes:
      - time_since_update
      - disk_name
      - read_count
      - write_count
      - read_bytes
      - write_bytes
    verify_ssl: false
    timeout: 20
    scan_interval: 8
  - platform: rest
    name: diskio_1
    resource: http://192.168.1.2:61208/api/3/diskio
    value_template: '{{ ( value_json[1] ) }}'
    json_attributes:
      - time_since_update
      - disk_name
      - read_count
      - write_count
      - read_bytes
      - write_bytes
    verify_ssl: false
    timeout: 20
    scan_interval: 8

  - platform: template
    sensors:
      horizon_c_drive_read_bytes:
        value_template: '{{ ((state_attr("sensor.diskio_0", "read_bytes") / state_attr("sensor.diskio_0", "time_since_update") | int) / 1000000) | round (2) }}'
        # value_template: '{{ ((state_attr("sensor.diskio_0", "read_bytes") | int) / 1000000) | round (2) }}'
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_c_drive_write_bytes:
        value_template: '{{ ((state_attr("sensor.diskio_0", "write_bytes") / state_attr("sensor.diskio_0", "time_since_update") | int) / 1000000) | round (2) }}'
        # value_template: '{{ ((state_attr("sensor.diskio_0", "write_bytes") | int) / 1000000) | round (2) }}'
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_e_drive_read_bytes:
        value_template: '{{ ((state_attr("sensor.diskio_1", "read_bytes") / state_attr("sensor.diskio_1", "time_since_update") | int) / 1000000) | round (2) }}'
        # value_template: '{{ ((state_attr("sensor.diskio_1", "read_bytes") | int) / 1000000) | round (2) }}'
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_e_drive_write_bytes:
        value_template: '{{ ((state_attr("sensor.diskio_1", "write_bytes") / state_attr("sensor.diskio_1", "time_since_update") | int) / 1000000) | round (2) }}'
        # value_template: '{{ ((state_attr("sensor.diskio_1", "write_bytes") | int) / 1000000) | round (2) }}'
        unit_of_measurement: 'MB/s'
  - platform: template
    sensors:
      horizon_gpu_name:
        value_template: '{{ state_attr("sensor.gpu", "name") }}'
        # value_template: '{{ states.sensor.gpu.attributes["name"] }}'
  - platform: template
    sensors:
      horizon_gpu_memory:
        value_template: '{{ state_attr("sensor.gpu", "mem") | round }}'
        # value_template: '{{ states.sensor.gpu.attributes["mem"] | round }}'
        unit_of_measurement: "%"
  - platform: template
    sensors:
      horizon_gpu_processor:
        value_template: '{{ state_attr("sensor.gpu", "proc") }}'
        # value_template: '{{ states.sensor.gpu.attributes["proc"] }}'
        unit_of_measurement: "%"
  - platform: template
    sensors:
      horizon_gpu_temperature:
        value_template: '{{ state_attr("sensor.gpu", "temperature") }}'
        # value_template: '{{ states.sensor.gpu.attributes["temperature"] }}'
        unit_of_measurement: "°C"
  - platform: template
    sensors:
      horizon_download_speed:
        value_template: '{{ ((state_attr("sensor.network", "rx") / state_attr("sensor.network", "time_since_update") | int) * 8 / 1000000) | round (2) }}'
        unit_of_measurement: "Mbps"
  - platform: template
    sensors:
      horizon_upload_speed:
        value_template: '{{ ((state_attr("sensor.network", "tx") / state_attr("sensor.network", "time_since_update") | int) * 8 / 1000000) | round (2) }}'
        unit_of_measurement: "Mbps"
  - platform: template
    sensors:
      horizon_total_speed:
        value_template: '{{ ((state_attr("sensor.network", "cx") / state_attr("sensor.network", "time_since_update") | int) * 8 / 1000000) | round (2) }}'
        unit_of_measurement: "Mbps"

1 Like

Hi guys, thanks so much for this. I am also fed up with IOT Link disconnections and want to switch to your solution.

How can you make glances -w to start at every boot?

Also i noticed that the order of the attache drives are inverted. For example, value_json[0] is the C drive, but then value_json[2] is not pointing at the E drive. instead it shows the drive usage % for the G drive. how can i see which value points to which drive?

thx!

If Glances is installed on Windows, you can install NSSM - the Non-Sucking Service Manager. It’s free and easy to setup. It will keep glances running as a Windows service (starting up automatically when Windows boots up). You can then execute python.exe glances-script.py or Glances.exe -w. I’m not sure about other OS’s; as, I’m a Windows guy.

An important thing to note is Home Assistant’s REST integration is currently not working correctly for Glances and other similar REST calls . A bug was introduced last year around November that hasn’t been fixed yet. They are currently working on a fix. In the meantime, you have to use the below workaround to keep REST working correctly with newer versions of Home Assistant until this issue is fixed:


The workaround is to downgrade the rest integration that still works correctly:


Please find my updated config in the below link. It supports almost all of Glances information and fixes many issues in the previous config I posted:
configuration.yaml (support for Glances)

Thank you so much mkanet. Really appreciated. I will go through carefully your message and links.

Hi mkanet, once again thanks so much for your kind and detailed help. super nice of you.

Just one question. how can i know which value_json[0] number point to which drive?
I can see that 0 is the c drive. but cant figure out the other drives (I have 4 plugged in).
Also i cannot find the glances config file in my roaming directory under appdate (windows 10).

Many thanks again.
EE

You’re welcome. It was very difficult for me to identify each drive too. I had to create artificial high data rate (transfer a very large file from network to each drive) to determine which drive (write) is active. I don’t know of any other way to do this, unfortunately.

EDIT: I also added a desktop screenshot feature just like IOT Link; except mine takes up a fraction of the CPU power to produce the screenshot; even at relatively quick intervals. I just have the below Windows batch file run at 30 second intervals via Windows scheduler (using nircmd.exe freeware utility)… copying an image file to my web server directly; which Home Assistant can display in realtime. I’m guessing you can do something similar with any other OS.

@ECHO ON
:START

nircmd.exe savescreenshot "C:\inetpub\wwwroot\today\screenshot.jpg"
sleep 20

GOTO START

Oh cool I love the desktop Screenshot feature. Thanks again so much.