VSCode Extension - 0.5.1 update available

Is your system running in simple mode?

If yes, the extension is not able to access items for preview.
Things should work all the time.

No, it’s not in simple mode. That’s what I meant by

:slight_smile:

@MriX

To be honest:
It is very difficult for me to catch the state of your personal environment.
Any information from your side is appreciated.
https can be done through more than a ngix reverse proxy which you seem to use.
I am not using a setup like this, so i depend on as much information as possible to get an impression of where the problem could have its roots.

What i can read from the posts above:
-> you are running openHAB behind an nginx reverse proxy (probably like it is done in the popular tutorial here)
-> you have configured nginx to listen for port 443 and nothing more
-> did you also configure it to forward port 5007 which is used hardcoded in openHAB for the language server
-> Is there anything additional that could be important for your environment?

I think i can’t do much debugging without a similar setup.
I could try to setup a reverse proxy too for testing purposes, but that will take time and i am not able to do this on short term.

@Udo_Hartmann

Sorry. This happens, when one answers from mobile while already in the personel sleep mode. :smile:

So some background:
Possibly its not the simple mode which is causing this problem. (In this case the error message would be wrong.)

Can you open the preview for a thing or does this throw an error too?
You could also test this in the browser for a thing and then try to use a equivalent edit url for an item to check the general ability paper ui is giving you currently.

I can provide a detailled example later, when i am at home.

Just activate Simple Mode in PaperUI, then save. Set it back and save again. This is one of the known bugs that no one seems to know :wink:

1 Like

Do you have a reference issue for that?
Maybe we should mention that somewhere.

I’m not sure if there’s an issue in GitHub, but it was already mentioned here.

@Confectrician

Here is some information:

  • openHAB is running on a Delian 9.9 server
  • There is a firewall (ufw) enabled and port 5007 for lsp is allowed (even disabling the whole firewall didn’t fixed the issue)
  • Nginx is setup to provide multiple sites on one port
server {
    listen 80;
    server_name     openhab.local
    return 301 https://$server_name$request_uri;
}

server {
    listen                          443 ssl;
    server_name                     openhab.local

    keepalive_timeout               64;

    ssl_certificate                 /etc/ssl/server2/server2-chained.crt;
    ssl_certificate_key             /etc/ssl/server2/server2.key;
    ssl_dhparam                     /etc/ssl/server2/dhparam.pem;
    ssl_protocols                   TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers                     'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    ssl_prefer_server_ciphers       on;
    ssl_session_cache               shared:SSL:10m;

    rewrite ^(/)$ https://$http_host/start/index;


    location / {
        proxy_pass                              http://localhost:8080/;
        proxy_set_header Host                   $http_host;
        proxy_set_header X-Real-IP              $remote_addr;
        proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto      $scheme;
        auth_basic                              "Username and Password Required";
        auth_basic_user_file                    /etc/nginx/.openhab_htpasswd;
    }

    location = /netdata {
        return 301 /netdata/;
    }

    location ~ /netdata/(?<ndpath>.*) {
        proxy_redirect                          off;
        proxy_set_header Host                   $host;

        proxy_set_header X-Forwarded-Host       $host;
        proxy_set_header X-Forwarded-Server     $host;
        proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
        proxy_http_version                      1.1;
        proxy_pass_request_headers              on;
        proxy_set_header Connection             "keep-alive";
        proxy_store                             off;
        proxy_pass                              http://127.0.0.1:19999/$ndpath$is_args$args;
        auth_basic                              "Username and Password Required";
        auth_basic_user_file                    /etc/nginx/.netdata_htpasswd;

        gzip                                    on;
        gzip_proxied                            any;
        gzip_types                              *;
    }

    location = /pihole {
        return 301 /pihole/;
    }

    location = /admin {
        return 301 /pihole/;
    }

    location = /admin/ {
        return 301 /pihole/;
    }

    location /pihole/ {
        proxy_pass                              http://localhost:8008/admin/;
        proxy_set_header Host                   $host;
        proxy_set_header X-Real-IP              $remote_addr;
        proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
        auth_basic                              "Username and Password Required";
        auth_basic_user_file                    /etc/nginx/.pihole_htpasswd;
    }
}

When I use port 8443 with the default openhab ssl encrypted connection I get the error unable to parse answer. When I add https:// I complains that the certificate is invalid (but trusted in Mac Keychain)
It only works correct when I use port 8080 default openhab configuration.

I think there is a bug in the extension. When somebody enters https:// for the openhab host, this should be removed when connecting to the LSP server because there is an other protocol used.

Yep, indeed that did the trick.

1 Like

GitHub Reference:

It seems that we have a problem with a library that we are using currently.
And aside i can tell you directly that this is out of my scope/knowledge on short term.
Sorry for this direct statement.
I am not happy with the situation and of course this is a thing that has to be fixed in the future.
But i can’t give you any timeframe for now.

I am not too familiar with the reverse proxy and nginx configuration.
Could you allow the computer you want to use vscode on a http connection through the nginx config?
I know that this is not the wanted solution, but maybe at least a temporary one.

Edit:

Some additional cutout which should be interesting for you an dother reverse proxy users:

Solution: Create a chained certificate like mentioned here in the NGINX documentation:

So this should be something we should at least document somewhere.

So my certificate chain is already done like in the Nginx documentation:

Nginx log:

IP - - [21/May/2019:21:13:16 +0200] "GET /rest/items/ HTTP/1.1" 400 271 "-" "-"
IP - user [21/May/2019:21:13:19 +0200] "GET /rest/things HTTP/1.1" 400 271 "-" "-"
IP - user [21/May/2019:21:13:19 +0200] "GET /rest/items HTTP/1.1" 400 271 "-" "-"

This is exactly my issue:

To allow the IP of my PC in the firewall would be a workaround, but not really satisfying.

Thanks for the additional information. :+1:

You can’t use https with the VSC extension for the LSP, I have tried. I think the issue is that it composes the address for the LSP like http://{openhab.host}:{openhab.remoteLspPort}. You can’t run it through Nginx because you would need to setup a sub directory and proxy it to 5007, so you would need to have the VSC extension try to access it via https://openhab.local/lsp for your example. However, consider the dangers, if you are connecting locally to your server then you shouldn’t need https because we should be able to assume that your local network is secure.

In order to be able to use the VSC extension through Nginx we would need the extension to allow setting the full address for each service. This would add complexity to the extension and its settings, which the developers might be against since most people are not running their OH behind Nginx.

As @David_Graeff mentioned in another thread - VSCode now has remote development capabilities. I don’t know if it would help in this case (and I haven’t tried with my setup yet) but you may want to google it (https://code.visualstudio.com/docs/remote/remote-overview)

The port 5007 is not running through Nginx, it is open in my firewall.
The issue is, that the host url ist used for connecting to LSP. Normally there should be only the IP used, so a regex to cut away the https:// part would be enogh

Oh I see, I misunderstood what you were trying to do. You are correct, the extension should take the protocol for http(s) as an additional setting, or as part of the uri and strip it for connecting to the LSP because it is not an http tunneled service.

Correct, the question is, who could implement that?

That shouldn’t be a big task at all, but I am not sure in which places it is used in the extension so we will have to identify the locations first.

Maybe I can spend some time next week to dig into that.

2 Likes

Maybe it was easier as thought.

I have added a PR and uploaded a packaged extension with the PR changes included.
Would be nice if you could test that @MriX.

See:

I still get this error message and the LSP does not work.

[Error - 3:15:55 PM] Connection to server is erroring. Shutting down server.

Also the basic ui preview of sitemaps is still just empty.

After I installed this extension I got a once-off “URI ERROR” dump each time I opened VScode.

Was able to find a solution see post.

Posted here for cross reference. Hope it is helpful.