openhab / openhab-vscode

VS Code extension for openHAB configuration files
https://marketplace.visualstudio.com/items?itemName=openhab.openhab
Eclipse Public License 2.0
159 stars 47 forks source link

LSP and REST via https not working together #83

Open lsiepel opened 6 years ago

lsiepel commented 6 years ago

When using https, i can't use LSP. Even when LSP port 5007 is reachable (local network)

With this workspace config i got REST to work, but LSP isn’t { "openhab.host": "https://my.domain.tld", "openhab.port": 443, }

When the config is changed to a fixed IP, the LSP is working but REST isn't. (nginx is set only to allow https on port 443) { "openhab.host": "192.168.1.255", "openhab.port": 443, }

Not sure how the host string is handled within the VS Code extension, but i guess https:// is not stripped when used for LSP server connection. Edit: Just checked https://github.com/openhab/openhab-vscode/blob/master/src/LanguageClient/LanguageClientProvider.ts and it's not stripped.

I would recommend an extra setting: openhab.usehttps {false|true} that defaults to false. And disallow any other string in openhab.host then DNS or IP. { "openhab.host": "my.domain.tld", "openhab.usehttps": true, "openhab.port": 443, }

That way it's more clear how https can be configured and you can use this new setting to support both LSP and REST at the same time when using https.

kubawolanin commented 6 years ago

Hey @lsiepel, Didn't test my setup with HTTPS so can't tell from experience, but the function that extracts host from configuration parameters is here -> https://github.com/openhab/openhab-vscode/blob/master/src/Utils.ts#L27

IMO there's no need to introduce a new configuration parameter if we can pass https to the URI string (https://abcd.tld or https://192.168.0.1). Maybe I'm missing something here. Anyways, feel free to submit a PR.

Also see #82 and this post - it contains not yet released version of the extension with a fix for REST connection.

lsiepel commented 6 years ago

Well, it might not be needed because it works, but imho the boolean is cleaner and clear from a user perspective. Anyway thanks for your comment, i installed the 0.3.5 from the file, but no luck.

Could it be that because the setting openhab.host is used for both UI-stuff (REST, classic ui etc.) and LSP, while containing the protocol, both have to be on the same protocol?

Many people make use of https because they have the openHAB accessible from the internet. But LSP is almost never publicly available and about nobody serves it by https. If this is the cause, i would suggest to be able to override the protocol for LSP in some VS Code setting.

I'm a C# and VS2015 amateur, before i make PR's i have a to learn a lot. :-)

pinkkoff commented 5 years ago

last comment was one year ago... Is there any way now to use https with domain name with auth, deny access to OH via LAN (only with proxy) and use LSP?

lsiepel commented 5 years ago

Well, i never managed to get it to work. IMHO, LSP and REST are two seperate consumable sources and they should be configurable individually. Unfortunately, im unable to construct a PR because of a lack of skills and time.

Confectrician commented 5 years ago

See my comment in another issue: https://github.com/openhab/openhab-vscode/issues/82#issuecomment-452362023

Probably this will be easier in the future. At least our local lsp should provide a good entry point with https enabled rest api. THere is a remote variant too, which may not work with a https only setting but there should at least be "some" functionality always.

Mr-iX commented 5 years ago

I have exactly the same issue in the current version.

I shared more information in this openHAB community thread: https://community.openhab.org/t/vscode-extension-0-5-1-update-available/74739/20