MiSchroe / klf-200-api

This module provides a wrapper to the REST API of a KLF-200 interface. Supporting the new API with firmware version 0.2.0.0.71 is in progress.
MIT License
38 stars 2 forks source link

KLF-200 stops responding after a while #106

Closed terafin closed 8 months ago

terafin commented 8 months ago

Thank you so much for this library!

Not sure this is an issue with the code here, but I've noticed I'm not able to connect to the KLF-200 unit after a while until rebooting it. (port 51200 is closed)

~ » sudo nmap -sT -p-  10.0.90.191                                                                                                                                                                                           terafin@home
Alias tip: _ nmap -sT -p-  10.0.90.191
[sudo] password for XXXXXX: 
Starting Nmap 7.80 ( https://nmap.org ) at 2024-02-25 12:31 PST
Nmap scan report for velux.XXXXXXXX (10.0.90.191)
Host is up (0.00045s latency).
Not shown: 65533 closed ports
PORT      STATE    SERVICE
1900/tcp  filtered upnp
60000/tcp filtered unknown

Nmap done: 1 IP address (1 host up) scanned in 6.02 seconds

Has anyone observed this behavior?

Note: You can see my connect usage of your library here: https://github.com/terafin/mqtt-velux-bridge/blob/a0c044d6ca3b8a5450fe07b2ebf313e977b5d333/index.js#L108

Aside: Should I be using the cert/fingerprint instead? (Why one vs the other?)

terafin commented 8 months ago

Note, post reboot:

Alias tip: _ nmap -sT -p-  10.0.90.191
Starting Nmap 7.80 ( https://nmap.org ) at 2024-02-25 12:56 PST
Nmap scan report for velux.XXXXXXX (10.0.90.191)
Host is up (0.00038s latency).
Not shown: 65532 closed ports
PORT      STATE    SERVICE
1900/tcp  filtered upnp
51200/tcp open     unknown
60000/tcp filtered unknown
MiSchroe commented 8 months ago

The KLF-200 closes the port after 15 minutes of inactivity. You could call gateway.getStateAsync() of the gateway e.g. every 5 minutes to keep up the connection. The KLF-200 also doesn't like to be flooded with parallel requests. Instead, queue your requests and run one after the other. The KLF-200 in itself is a little bit unstable. Think about rebooting it on a regular basis, e.g. during the night when it's not in use. See https://github.com/MiSchroe/ioBroker.klf200 as a reference how this library is used successfully.

terafin commented 8 months ago

Thanks so much for the pointers! I guess I'll have to do an auto reboot when I restart the docker container for it, or it detects it's dropped connection. :)