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

Error: Could not get valid data from REST API #201

Open fwolter opened 4 years ago

fwolter commented 4 years ago

I'm getting the following error, when connecting to my openHAB instance, running behind a nginx reverse proxy with Basic Auth and Letsencrypt with redirection to SSL:

Error: Could not get valid data from REST API
    at U._callback (c:\Users\fab\.vscode\extensions\openhab.openhab-0.7.0\serverJS\out\LSPServer.js:135:130206)
    at U.t._callback.t.callback.t.callback (c:\Users\fab\.vscode\extensions\openhab.openhab-0.7.0\serverJS\out\LSPServer.js:195:5603)
    at U.emit (events.js:203:13)
    at U.<anonymous> (c:\Users\fab\.vscode\extensions\openhab.openhab-0.7.0\serverJS\out\LSPServer.js:195:18463)
    at U.emit (events.js:203:13)
    at IncomingMessage.<anonymous> (c:\Users\fab\.vscode\extensions\openhab.openhab-0.7.0\serverJS\out\LSPServer.js:195:17295)
    at Object.onceWrapper (events.js:291:20)
    at IncomingMessage.emit (events.js:208:15)
    at endReadableNT (_stream_readable.js:1168:12)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)

When looking into the TCP stream, I see VSCode gets redirected via port 80 to 443 and then continues encrypted. The connection to the LSP on port 5007 seems to work. Accessing the REST API via browser do work and connecting VSCode to the REST API of my local openHAB instance work, too.

This is my config: grafik

Tried already port 443 or connecting by IP address.

VSCode openHAB 0.7.0 openHAB 2.5.3

Confectrician commented 4 years ago

It seems that the local LSP server cant handle the basic auth connection. IT seems to not get dactivated fully, when remote lsp is active.

Reference: https://github.com/openhab/openhab-vscode/blob/master/serverJS/src/ItemCompletion/ItemCompletionProvider.js#L153

This seems like a hardcoded url.

fwolter commented 4 years ago

I just wanted to reproduce the error, but now, everything works. I didn't change anything by intention... Observing it.

Confectrician commented 4 years ago

Thanks for the Feedback. I have a guess then.

Maybe we have some cached data that caused trouble. I recently read from bug reports which seem to solve themselves. Maybe we should check if we can provide some sort of caching override for settings.

KHOne23 commented 3 years ago

I am faceing the same Problem when i have installed the Amazon Echo Control Binding. When i deinstall it everything works fine. when i reinstall it i am faceing this error

heimerle commented 3 years ago

@Confectrician basically i am facing the same problem, but i can confirm the hard coded URL problem, when adding /rest/items to the openHab.host config, at least the items occur in VS Code, for things i am still getting the error message "Error while connecting to REST API"