rudders / homebridge-http

HTTP Plugin for Homebridge
Apache License 2.0
178 stars 110 forks source link

EHOSTUNREACH: Handling powered off device. #28

Closed m600x closed 7 years ago

m600x commented 8 years ago

When running Hombridge along with this plugin, if by any mischance the device is getting powered off, this plugin cause a crash instead of juste returning an error to homebridge. So even with a deamon to restart homebridge, the app will keep crashing without knowing the cause of the defective element.

Don't know if it's the expected behavior or an unprotected event. (Solved similar error with Socket hanging and so on by increasing the polling interval).

The accessories is configured as such:

"accessory":            "Http",
"name":                 "cuisine",
"switchHandling":       "realtime",
"http_method":          "GET",
"on_url":               "http://192.168.0.100/onurl",
"off_url":              "http://192.168.0.100/offurl",
"status_url":           "http://192.168.0.100/status",
"service":              "Light",
"brightnessHandling":   "no"

Here is the trace of a crash:

` [2016-04-26 23:33:48] [cuisine] HTTP get power function failed: connect EHOSTUNREACH 192.168.0.100:80 /usr/lib/node_modules/homebridge-http/index.js:45 callback(error); ^

ReferenceError: callback is not defined at /usr/lib/node_modules/homebridge-http/index.js:45:19 at Request._callback (/usr/lib/node_modules/homebridge-http/index.js:115:4) at self.callback (/usr/lib/node_modules/homebridge-http/node_modules/request/request.js:200:22) at emitOne (events.js:77:13) at Request.emit (events.js:169:7) at Request.onRequestError (/usr/lib/node_modules/homebridge-http/node_modules/request/request.js:831:8) at emitOne (events.js:77:13) at ClientRequest.emit (events.js:169:7) at Socket.socketErrorListener (_http_client.js:256:9) at emitOne (events.js:77:13) `

jb2b38 commented 8 years ago

I have this exact same error message when using the line "switchHandling", everything works when I remove it. Not sure what is the role of switchHandling since it's not documented on the main page, but removing it did the trick for me.

d0n13 commented 8 years ago

I had my node.js server running my hardware and using homebridge on the raspberry as well so I needed to start the node.js server before homebridge. Been tearing my hair out for hours trying to get the startup dependencies right but everytime it failed to start homebridge.

It would start ok on the command line.

Removing switchHandling from the config.json for homebridge also solved this for me.

Thanks guys