fdegier / homebridge-jablotron-alarm

Homebridge plugin for connecting Jablotron JA-100 alarm systems to Homekit.
The Unlicense
26 stars 6 forks source link

Homebridge crashes #44

Closed grzegorz914 closed 4 years ago

grzegorz914 commented 4 years ago

Hi,

please look at this crashlog:

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/homebridge-jablotron/lib/jablotron-client.js:56:38)
    at IncomingMessage.emit (events.js:333:22)
    at endReadableNT (_stream_readable.js:1201:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
MaLi812 commented 4 years ago

Same here. And no sign in MyJablotron-App possible. Maybe a server problem?

misncz commented 4 years ago

Yes, server problem

grzegorz914 commented 4 years ago

if server make problems, plugin cannot crash the homebridge

fdegier commented 4 years ago

@grzegorz914 you are right, it is not programmed defensively enough. But I'm not sure what we should give back if the system is down, I'm not aware of a state of error.

And I would prefer to see an error than to have it return some value and not knowing if that value is the actual value or an error value.

Any ideas?

grzegorz914 commented 4 years ago

Now we get this without Homebridge crash:

[3/5/2020, 7:37:58 PM] [Alarm] {
  status: false,
  error_status: 'service_unavailable',
  error_message: 'The service is not available.',
  checksum: '01b7cd8d40b14b97cbe8364440d285c1',
  server_id: 'xxxxxxxxxxxxx',
  client_id: null
}
[3/5/2020, 7:37:58 PM] [Alarm] Error: service_unavailable
    at /usr/lib/node_modules/homebridge-jablotron/lib/jablotron-client.js:25:31
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/homebridge-jablotron/lib/jablotron-client.js:56:17)
    at IncomingMessage.emit (events.js:333:22)
    at endReadableNT (_stream_readable.js:1201:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

If server is down return error value and prevent homebridge crash.

fdegier commented 4 years ago

Ok gotcha.

The server seems to be working again, however for me Home app still does not update.

fdegier commented 4 years ago

New error:

[3/5/2020, 7:16:23 PM] [Jablotron] { Error: getaddrinfo EAI_AGAIN api.jablonet.net api.jablonet.net:443
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
  errno: 'EAI_AGAIN',
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: 'api.jablonet.net',
  host: 'api.jablonet.net',
  port: 443 }