Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while connecting to openHAB REST API #57

Closed
paulianttila opened this issue Nov 18, 2017 · 33 comments
Closed

Error while connecting to openHAB REST API #57

paulianttila opened this issue Nov 18, 2017 · 33 comments
Labels

Comments

@paulianttila
Copy link

VS code extension given an error "Error while connecting to openHAB REST API". File editing works fine (via samba share).

Versions:

Visual Studio code: 1.18.1
openHAB VS Code Extension: 0.3.0
OS: macOS 10.13 High Sierra

openHAB: 2.2.0~20171018133740-1
OS: Linux version 4.4.0-96-generic

settings.json

{
    "files.associations": {
        "*.log": "properties"
    },
    "workbench.iconTheme": "openhab",
    "openhab.host": "192.168.10.7",
    "openhab.port": 8080
}

Wireshark:
192.168.10.22 = Visual Studio
192.168.10.7 = openHAB
screen shot 2017-11-18 at 11 51 54

@paulianttila
Copy link
Author

Items fetch seems to work at least partly. When I press refresh button from VS, item states are refreshed (not sure if all) but with same error.

Things panel doesn't show anything.

screen shot 2017-11-18 at 19 02 53

@kubawolanin
Copy link
Collaborator

Hey @paulianttila thanks for reporting!
Could you open http://192.168.10.7:8080/rest/things and see if it returns anything?
I'm relying on the REST API all the way, so if it's a problem on the distro, there's likely some log in your openhab.log file telling you what's up :-)

Try restarting your openhab instance and see if http://192.168.10.7:8080/rest/things loads in your browser. Maybe it's some issue in your *.things files?

Anyways, I'm keeping this issue open. I'll think of better error handling in that scenario.

Cheers

@fseffert
Copy link

Hey... same problem for me! I noticed that in my settings.json the openhab.host setting gets always overwritten with "localhost".
I can access the rest api with my browser without problems!

@paulianttila
Copy link
Author

@kubawolanin, both items and things files can be fetched fine via browser and JSON is valid (tested with another tool). Also Paper UI works fine.

OpenHAB log doesn't show anything suspicious.

@kubawolanin
Copy link
Collaborator

@paulianttila @fseffert could you be so kind and test if problem still occurs on your machines with the attached extension?

openhab-0.3.0.vsix.zip
Just unzip it and install manually.

Follow this post to see how to install the extension manually from VSIX.

Cheers!

@paulianttila
Copy link
Author

@kubawolanin, just tested new version. Unfortunately, with the same result. Does extension do any kind of logging?

If I press "OPENHAB ITEMS" or "OPENHAB THINGS" panels refresh icon, it downloads both items and things files nicely (seen from wireshark) but it gives the same error message. Items panel is refreshed and things panel stays empty.

@paulianttila
Copy link
Author

VS developer tools shows two errors

messageService.ts:126 Error while connecting to openHAB REST API. 
e.doShow @ messageService.ts:126
e.show @ messageService.ts:105
e._showMessage @ mainThreadMessageService.ts:72
n.Class.derive._oncancel @ winjs.base.raw.js:1641
e._showMessage @ mainThreadMessageService.ts:42
e.$showMessage @ mainThreadMessageService.ts:36
e.invoke @ abstractThreadService.ts:41
e._invokeHandler @ rpcProtocol.ts:109
e._receiveOneMessage @ rpcProtocol.ts:96
(anonymous) @ rpcProtocol.ts:32
(anonymous) @ rpcProtocol.ts:157
e.invoke @ callbackList.ts:36
e.fire @ event.ts:123
(anonymous) @ ipc.net.ts:82
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560
shell.ts:459 Please return an array of children.: Error: Please return an array of children.
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:236755
    at Object.g [as _notify] (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:62701)
    at Object.enter (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:66048)
    at n.Class.derive._oncancel._run (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:67876)
    at n.Class.derive._oncancel._completed (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:67317)
    at e.resolveOk (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:2438440)
    at e._receiveOneMessage (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:2439971)
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:2439283
    at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:2441202
    at e.invoke (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:9:82095)
e.onUnexpectedError @ shell.ts:459
(anonymous) @ shell.ts:419
e.onUnexpectedError @ errors.ts:119
o @ errors.ts:138
v @ winjs.base.raw.js:1209
enter @ winjs.base.raw.js:901
_run @ winjs.base.raw.js:1068
_chainedError @ winjs.base.raw.js:1031
n @ winjs.base.raw.js:736
then @ winjs.base.raw.js:1436
enter @ winjs.base.raw.js:747
_run @ winjs.base.raw.js:1068
_setCompleteValue @ winjs.base.raw.js:1052
g @ winjs.base.raw.js:1170
enter @ winjs.base.raw.js:852
_run @ winjs.base.raw.js:1068
_completed @ winjs.base.raw.js:1036
e.resolveOk @ lazyPromise.ts:65
e._receiveOneMessage @ rpcProtocol.ts:72
(anonymous) @ rpcProtocol.ts:32
(anonymous) @ rpcProtocol.ts:157
e.invoke @ callbackList.ts:36
e.fire @ event.ts:123
(anonymous) @ ipc.net.ts:82
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560

@kubawolanin
Copy link
Collaborator

Hmm so the error message comes from this file which is a part of vscode's framework for tree views.

@fseffert can you share more info on your environment? Is it a Mac as well?

I've encountered some issues with the latest SNAPSHOT build so the problem could be partially related with it too. After downgrading my openHAB to distro # 1082 everything went back to normal (no weird log messages, problems with REST API endpoints loading etc).

I will, however, work on the solution on my side and hopefully we'll find what's the real issue.

In the meantime, here's the package with some more fixes on my side:
openhab-0.3.0.zip

@dartrax
Copy link

dartrax commented Nov 20, 2017

Hello,
I'm having the same issue. I freshly set up openHABian last weekend and Visual Studio Code with this extension. I get the same two errors in VS developer tools that @paulianttila already posted.
http://rapb-pi-IP:8080/rest/things seems to be working.
I did not test with the new vsix.

Visual Studio code: 1.18.1 x64
openHAB VS Code Extension: 0.3.0
OS: Win 10 Version 1703

@kubawolanin
Copy link
Collaborator

@dartrax what version of openHAB are you running? Is it by any chance build # 1084 or 1083? See this post for details. The build has some runtime bugs.

Please test the extension from my previous post. I will merge it and publish it as soon as I'm sure the error doesn't occur anymore.

@dartrax
Copy link

dartrax commented Nov 20, 2017

Hi, I have

openHAB Distribution Version Information
----------------------------------------
build-no        : - release build -
online-repo     : https://dl.bintray.com/openhab/mvn/online-repo/2.1

Repository        Version
----------------------------------------
openhab-distro  : 2.1.0
smarthome       : 0.9.0.b5
openhab-core    : 2.1.0
openhab1-addons : 1.10.0
openhab2-addons : 2.1.0
karaf           : 4.0.8

and I don't know which build number that represents.
I also tried the extension from your post. I uninstalled the old one, restart, installed it from vsix, restart, checked the settings, but still the same.

{
    "openhab.host": "192.168.178.41",
    "openhab.port": 8080,
    "openhab.useRestApi": true
    /*"openhab.username": "openhabian",
    "openhab.password": "openhabian"*/
}

@kubawolanin
Copy link
Collaborator

@dartrax looks like you're using the release build (2.1) and not the SNAPSHOT.
If the following command on your openHABian doesn't return a number, it confirms it:

sed -n 's/build-no\s*: //p' /var/lib/openhab2/etc/version.properties | cut -d '#' -f 2

If that's the case, please try to add the following line to your settings:

"openhab.lspEnabled": false

Also, there might be a need to reload VSCode window each time you change your settings.
Simply hit Ctrl + Shift + P and type "Reload window"

Cheers

@dartrax
Copy link

dartrax commented Nov 20, 2017

Yes, I'm using the release build (2.1)
I added that line to my settings and "reload window", but it still does not work.
One thing I noticed: Even with the setting
"openhab.useRestApi": false
I'm still getting the "Error while connecting to openHAB REST API"-Message.

@paulianttila
Copy link
Author

paulianttila commented Nov 20, 2017

@kubawolanin, I forgotten to inform you yesterday that I tested your latest extension without success.

@kubawolanin
Copy link
Collaborator

@paulianttila @fseffert @dartrax here's the updated extension, available also in #58.
openhab-0.3.0.zip

@dartrax
Copy link

dartrax commented Nov 21, 2017

I tried the updated extension. No Error message anymore, but Sitemap preview, Things and Items Panel stay empty.
Developer tools still say:

shell.ts:459 Please return an array of children.: Error: Please return an array of children.
    at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:236755
    at Object.g [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:62701)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:66048)
    at n.Class.derive._oncancel._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:67876)
    at n.Class.derive._oncancel._completed (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:67317)
    at e.resolveOk (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:2438440)
    at e._receiveOneMessage (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:2439971)
    at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:2439283
    at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:2441202
    at e.invoke (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:9:82095)

@paulianttila
Copy link
Author

Updated the latest extension and behaviour is exactly same as @dartrax have.

@sjsf
Copy link

sjsf commented Nov 24, 2017

while trying to fix eclipse-archived/smarthome#4601 I just ran into the same issue after a couple of restarts. Maybe something got updated silently under the hood? In any case, all the openHAB windows are empty and it also doesn't even try to connect to the LSP backend anymore.

Let me know if (and how) I can help with the analysis.

@kubawolanin
Copy link
Collaborator

This bugs me because I couldn't reproduce this bug even once.
I'm running Windows 10, VSCode 1.18.1 and openHAB distro 1094.

I've pushed some changes to #58 - I would really appreciate if you could test the extension again:
openhab-0.3.0.zip

Exact steps to reproduce would be also really helpful.

@jewesta
Copy link

jewesta commented Nov 24, 2017

For what it's worth: I'm running a similar environment as @paulianttila except for I'm on a Raspberry and distro #1094. I have not seen this error.

I tried 0.3.0 #58 just out of curiosity. It does not change anything on my side. So I'm still getting those path / code checking / hover problems (NPEs in the logs etc.) but it does not make anything worse either.

@paulianttila
Copy link
Author

@kubawolanin, just tried the latest version (also reinstalled VSCode). Items works fine, but things panel stays empty.

Console:

messageService.ts:126 Error while connecting to openHAB REST API. 
e.doShow @ messageService.ts:126
e.show @ messageService.ts:105
e._showMessage @ mainThreadMessageService.ts:72
n.Class.derive._oncancel @ winjs.base.raw.js:1641
e._showMessage @ mainThreadMessageService.ts:42
e.$showMessage @ mainThreadMessageService.ts:36
e.invoke @ abstractThreadService.ts:41
e._invokeHandler @ rpcProtocol.ts:109
e._receiveOneMessage @ rpcProtocol.ts:96
(anonymous) @ rpcProtocol.ts:32
(anonymous) @ rpcProtocol.ts:157
e.invoke @ callbackList.ts:36
e.fire @ event.ts:123
(anonymous) @ ipc.net.ts:82
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560

@kubawolanin
Copy link
Collaborator

@paulianttila thank you!
Could you visit http://192.168.10.7:8080/paperui/index.html#/configuration/things and tell me if all your Things have labels?

@kubawolanin
Copy link
Collaborator

Ah, turns out that the Things comparator was taking only label into consideration! :-)
It's resolved now! :)

@paulianttila
Copy link
Author

@kubawolanin, that's great. Do you have new version available?

@kubawolanin
Copy link
Collaborator

Sure thing! I'll prepare a new release in the next few days. In the meantime, here's the packaged VSIX:
openhab-0.3.0.zip

Thanks for your help!

@paulianttila
Copy link
Author

I can also verify that thing problem is now fixed. Thank you @kubawolanin.

@dartrax
Copy link

dartrax commented Nov 25, 2017

I tried the updated extension. The Error message ist back, Sitemap preview, Things and Items Panel stay empty.
Developer tools say:

  | e.doShow | @ | messageService.ts:126
-- | -- | -- | --
  | e.show | @ | messageService.ts:105
  | e._showMessage | @ | mainThreadMessageService.ts:72
  | n.Class.derive._oncancel | @ | winjs.base.raw.js:1641
  | e._showMessage | @ | mainThreadMessageService.ts:42
  | e.$showMessage | @ | mainThreadMessageService.ts:36
  | e.invoke | @ | abstractThreadService.ts:41
  | e._invokeHandler | @ | rpcProtocol.ts:109
  | e._receiveOneMessage | @ | rpcProtocol.ts:96
  | (anonymous) | @ | rpcProtocol.ts:32
  | (anonymous) | @ | rpcProtocol.ts:157
  | e.invoke | @ | callbackList.ts:36
  | e.fire | @ | event.ts:123
  | (anonymous) | @ | ipc.net.ts:82
  | emitOne | @ | events.js:96
  | emit | @ | events.js:191
  | readableAddChunk | @ | _stream_readable.js:178
  | Readable.push | @ | _stream_readable.js:136
  | onread | @ | net.js:560

"Please return an array of children." seems to be gone.

@LiPoPower
Copy link

Hello,
same problem here
Installed openhab 2.2.0 running in a docker container under Linux , VS openhab-Extension 0.35.
The restapi seems functional, "http://raspi3:8080/rest/things" returns things.
Like to give you more info, but i'm totally new to VS Code.
Maybe you can guide me to necessary additonal info?

@kubawolanin
Copy link
Collaborator

@LiPoPower take a look at #67 - it might be related.

@LiPoPower
Copy link

Ups, sorry for that: did the customizations in vs user preferences. #Moved it to workspace preferences now it works like charm...

@dannycohn
Copy link

This problem just crept up for me. I am running 0.3.5 of the plugin. It was working fine until some time recently. I'm not sure what thing/item I might have added that caused the problem. Is there an easy way to debug to help get to the bottom of it?

@mloetscher
Copy link

I have exactly the same issue (openHAB 2.2, plugin 0.3.5, rest api works fine) - doesn't work with user and/or workspace preferences... Any update on this?

@mloetscher
Copy link

I just erased my .items file (which was only copied from the example, no correct values in it) and restarted openhab - now it works... Looks like the plugin has some issues with error handling...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants