SphtKr / homebridge-zway

Homebridge plugin for (better) HomeKit support of RaZBerry and Z-Way Server
ISC License
85 stars 37 forks source link

error:HPE_UNEXPECTED_CONTENT_LENGTH on startup #90

Open loautomation opened 7 years ago

loautomation commented 7 years ago

Hi!

I have recently started to use homebridge and it works nicely using one of the http plugins, I can manage http-based devices that way. I really would like to control my zwave devices as well but I can not seem to get the zway plugin to start. I installed the homebridge using sw on a raspberry pi 3 sudo npm install -g --unsafe-perm homebridge

node.js install: wget https://nodejs.org/dist/v4.3.2/node-v4.3.2-linux-armv6l.tar.gz node -v -> v4.3.2

I get this error message when I try to start homebridge manually: "ERROR: Request failed! Error code HPE_UNEXPECTED_CONTENT_LENGTH. Check the URL in config.json and ensure that the URL can be reached from this system!"

I use raspberry pi with the Razberry and that works great by it self not using the homebridge. I can browse to my Razberry pi using: http://ip:8083 and get elements etc and the I just checked the version and the zwave version is 2.2.1.

config.json: { "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 51826, "pin": "031-45-154" }, "description": "Z-Wave controller", "platforms": [ { "platform": "ZWayServer", "url": "http://ip:8083/", "login": "myuser", "password": "12345678" } ] }

SphtKr commented 7 years ago

I think this is a known issue with Z-Way <= 2.2.1 and newer node versions that fixed a security vulnerability. If you're running a recent NodeJS 4, 5, 6, or 7, that bug in Z-Way is probably the problem (see #14 if you're interested in more information).

You should probably upgrade to Z-Way 2.2.2 or greater. If there's some reason you can't, you can downgrade Node to Node 4.2.x or Node 5.5.x, but this is not recommended. Update Z-Way if you can.

loautomation commented 7 years ago

I have performed the upgrade(2.2.2) and error is still current... I manage to talk to my razberry using the Zway automation API without problems reading sensors and turning lamps on and off so I guess it is something on the homebridge/plugin side. I use the http plugin for homebridge until I sort out this problem. I have written a small REST service that lets me control the z-wave devices using the zway API but I really would like the plugin to work...

I have NodeJS:v4.3.2, Razberry FirmWare: v2.2.2, zway v2.2.2 Can anybody chime in what combination of software versions that can use the plugin Homebridge: Nodejs version: Razberry: firmware version Raberry: zway version

Error message when starting homebridge ERROR: Request failed! Error code HPE_UNEXPECTED_CONTENT_LENGTH. Check the URL in config.json and ensure that the URL can be reached from this system!

SphtKr commented 7 years ago

That's really surprising to me... That error code (HPE_UNEXPECTED_CONTENT_LENGTH) is exactly what would happen with the old HTTP code in Z-Way after NodeJS implemented a security patch. Here's the thread on the Z-Wave.me forums that talks about it more generally--it affected more than just this plugin.

Now, when they implemented a fix, they published it as v2.2.2-test-new-webserver. If memory serves (and if I understood it right at the time), that was a pre-release version of v2.2.2, and the release version of 2.2.2 came after it and should have included the new HTTP server code...but maybe I misunderstood/misremembered? I actually never ran vanilla v2.2.2, only the test-new-webserver release. My point being, it's possible I was wrong and that fix wasn't available until v2.2.3. So...try that version? Sorry if that's it and I gave you the wrong version number to upgrade to.

FWIW, downgrading Z-Way is pretty easy, the upgrade process creates a dated directory with your previous version in /opt/, so you just stop the Z-Way services, move the new one aside and move the old one back into place. So I think you shouldn't worry too much about upgrading breaking things. (But double-check me on Google about that procedure, I've either never actually done it or it's been a long time.)