Closed gruberth closed 1 year ago
The IP field must not be left empty. Please enter your internal IP adrress there. There is some info on this topic in the forum, e.g. here: https://knx-user-forum.de/forum/supportforen/smartvisu/1727326-neuer-smarthomeng-treiber
I got your idea, but I don't want to use the local IPv4 when calling the visu via the local hostname https://visu.something.org/ , because in that case the SSL certificate for the websoket (which is than wss://192.168....:2425 rather than wss://visu.something.org/ :2425) is not valid. When leaving the IP field empty, the driver chooses the location.hostname which is always correct for me.
But I think I am facing a verry special problem, which others don't have, so maybe i just dublicate the driver and extend it with my needs.
Thanks
The driver checks if location.hostname is an IPv4 address (internal). If not, it checks whether location.hostname is identical with the configured smartVISU hostname. Then, it considers the connection internal and uses the address specified in config. Otherwise it will use location.hostname and Port 80/443 for the websocket.
To call smartVISU with a local hostname you just need to enter the local hostname in the config section "smartvisu hostname". Then it should also be possible to use a local hostname for the websocket instead of the IP address.
If you test that we can jointly develop a better solution which fits best for all users.
I need the following three connections:
The first connection is mainly used for static devices like a wall mounted tablet and for a fallback solution if the DNS goes down. The mainly used connection for smartphones and other devices is the last one over wss.
In my config i have the following entries:
IP: 192.168.X.X ws port: 2424 wss port: 2425 hostname: visu.something.com
Connection type one and two works obviously great. But because of the hostname entry the connection three tries to connect over wss://192.168.X.X:2425, but since the SSL certificate is granted for visu.something.com the connection gets rejected. A temporary solution is to enter wss://192.168.X.X:2425 in the URL field of the used browser and advice it to ignore the SSL warning and continue anyway, but this shouldn't be the way to go. And by adding the hostname in the IP field by hard I don't have a fallback for the DNS crash scenario.
I can't figure out how to properly fix the connection settigs to satisfy all the needs. The olnly thing thats in my mind is the way to add the connection settings part twice in the config page, maybe without the hostname section. So everybody can enter their preferred and their fallback settings. So on connection init the driver has to check if the preferred one is reachable and if not it should immediately try to connect to the fallback. This means also if the preferred connection is a reverse proxy you have to enter 443 as wss port.
By the way, I deploy also a second SMNG and SV installation with an reverse proxy server. This one works great with the actual possibilities of connection settings. It works like you intended: through the reverse proxy and via local access.
You could try the following patch in io_smarthomeng.js (not tested):
init: function () {
io.address = sv.config.driver.address;
// if user-called host is not an IP v4 address check if called host is internal hostname of smartVISU server or configured tlsaddress
// otherwise assume that call comes from external and then empty io.address
if (!$.isNumeric(location.hostname.split('.').join(''))) { // replaceAll() does not work for old browsers
if (sv.config.driver.tlsaddress && sv.config.driver.tlsaddress != '' && location.hostname == sv.config.driver.tlsaddress)
io.address = sv.config.driver.tlsaddress;
else if ( location.hostname != sv.config.svHostname )
io.address = '';
}
io.open();
},
and then just specify driver_tlsaddress = "visu.something.com"
manually in config.ini.
Now tested - should work ;) I'll rather call it sv.config.driver.address2 (driver_address2 in config.ini). If you confirm the test I'll push this into the develop branch. The feature will be documented in the source code but there will not be an additional option on the config page - just to keep config as simple as possible for the users.
Tested and it works great! All the connections and ports are now as I need them. Great and simple solution 👍
Thank you
pushed into develop w/ #823
I think this if https://github.com/Martin-Gleiss/smartvisu/blob/63747bb1552b4e419438d77c300f784d96a999f0/driver/io_smarthomeng.js#L135
should be dropped, like it was in the lately removed smarthomepy driver.
For example I am using the SV from local http://192.168.... and from https://visu.something.org via DNS. So I need to specify the ports to 2424 for ws:// and 2425 for wss:// and the ip field remains empty. If this
io.adress
check is present the driver chooses always the port 443 for https://visu.something.org (which ist incorrect because I am not using a reverse proxy server) instead of the 2425 entry.