From 0092f94e918ade7a7b14dca14d604228fbaef35f Mon Sep 17 00:00:00 2001 From: Moritz Heusinger Date: Thu, 11 Feb 2021 12:44:36 +0100 Subject: [PATCH] chore: release v1.14.34 use async rpc calls for better error handling now log error events received by XML-RPC detect invalid params and log instead of crash --- README.md | 4 +++- io-package.json | 26 +++++++++++++------------- main.js | 29 ++++++++++++++++++++--------- package-lock.json | 2 +- package.json | 2 +- 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ab84f9db..a6aa67bc 100644 --- a/README.md +++ b/README.md @@ -150,8 +150,10 @@ by ioBroker, when you have a running 'dummy' program on the CCU which depends on ### __WORK IN PROGRESS__ --> -### __WORK IN PROGRESS__ +### 1.14.34 (2021-02-11) * (foxriver76) use async rpc calls for better error handling +* (foxriver76) now log error events received by XML-RPC +* (foxriver76) detect invalid params and log instead of crash ### 1.14.33 (2021-01-30) * (foxriver76) fix problems with CuxD and HMIP (fixes #307) diff --git a/io-package.json b/io-package.json index 8e6774e1..4c8ac6bb 100644 --- a/io-package.json +++ b/io-package.json @@ -13,8 +13,20 @@ "es": "Conecta los Procesos de Interfaz HomeMatic (BidCos-Services, Homegear y CUxD) a través de XML-RPC o BIN-RPC a ioBroker", "pl": "Łączy procesy HomeMatic-Interface (BidCos-Services, Homegear i CUxD) za pośrednictwem XML-RPC lub BIN-RPC z ioBroker" }, - "version": "1.14.33", + "version": "1.14.34", "news": { + "1.14.34": { + "en": "use async rpc calls for better error handling\nnow log error events received by XML-RPC\ndetect invalid params and log instead of crash", + "de": "Verwenden Sie asynchrone RPC-Aufrufe für eine bessere Fehlerbehandlung\nProtokollieren Sie jetzt von XML-RPC empfangene Fehlerereignisse\nErkennen Sie ungültige Parameter und protokollieren Sie anstelle eines Absturzes", + "ru": "используйте вызовы async rpc для лучшей обработки ошибок\nтеперь записывать события ошибок, полученные XML-RPC\nобнаруживать недопустимые параметры и регистрировать вместо сбоя", + "pt": "use chamadas rpc assíncronas para melhor tratamento de erros\nagora registra eventos de erro recebidos por XML-RPC\ndetectar parâmetros inválidos e registrar em vez de travar", + "nl": "gebruik asynchrone rpc-oproepen voor betere foutafhandeling\nlog nu foutgebeurtenissen die zijn ontvangen door XML-RPC\ndetecteren ongeldige parameters en log in plaats van crash", + "fr": "utiliser les appels async rpc pour une meilleure gestion des erreurs\nenregistre maintenant les événements d'erreur reçus par XML-RPC\ndétecter les paramètres invalides et enregistrer au lieu de planter", + "it": "usa chiamate rpc asincrone per una migliore gestione degli errori\nora registra gli eventi di errore ricevuti da XML-RPC\nrileva parametri e log non validi invece di crash", + "es": "use llamadas async rpc para un mejor manejo de errores\nahora registra los eventos de error recibidos por XML-RPC\ndetectar parámetros inválidos y registrar en lugar de fallar", + "pl": "użyj asynchronicznych wywołań RPC dla lepszej obsługi błędów\nteraz rejestruj zdarzenia błędów odebrane przez XML-RPC\nwykrywa nieprawidłowe parametry i rejestruje zamiast awarii", + "zh-cn": "使用异步rpc调用以更好地处理错误\n现在记录XML-RPC收到的错误事件\n检测无效的参数并记录而不是崩溃" + }, "1.14.33": { "en": "fix problems with CuxD and HMIP (fixes #307)\nmore palces where we now log message on real errors instead of error object", "de": "Beheben Sie Probleme mit CuxD und HMIP (behebt # 307)\nWeitere Palces, in denen wir jetzt Nachrichten über echte Fehler anstelle von Fehlerobjekten protokollieren", @@ -242,18 +254,6 @@ "es": "eliminó completamente el almacenamiento en caché de metadatos porque los metadatos pueden ser dinámicos debido a la actualización de FW o CuxD", "pl": "całkowicie usunięto buforowanie metadanych, ponieważ metadane mogą być dynamiczne z powodu aktualizacji FW lub CuxD", "zh-cn": "完全删除了元数据缓存,因为由于固件更新或CuxD,元数据可以是动态的" - }, - "1.14.6": { - "en": "added some hmip roles for channel 0", - "de": "Einige hmip-Rollen für Kanal 0 wurden hinzugefügt", - "ru": "добавлены некоторые роли hmip для канала 0", - "pt": "adicionou algumas funções hmip para o canal 0", - "nl": "enkele hmip-rollen toegevoegd voor kanaal 0", - "fr": "ajout de quelques rôles hmip pour le canal 0", - "it": "aggiunti alcuni ruoli hmip per il canale 0", - "es": "se agregaron algunos roles hmip para el canal 0", - "pl": "dodano kilka ról hmip dla kanału 0", - "zh-cn": "为频道0添加了一些hmip角色" } }, "authors": [ diff --git a/main.js b/main.js index 480231e0..643972d7 100644 --- a/main.js +++ b/main.js @@ -395,15 +395,22 @@ async function readSettings(id) { controlEPaper(id, data); } // endReadSettings -// the adapter object - function startAdapter(options) { options = options || {}; Object.assign(options, { name: adapterName, + error: e => { + if (e.code === 'EADDRNOTAVAIL') { + adapter.log.error(`Address ${adapter.config.adapterAddress} not available, maybe your HOST IP has changed due to migration`); + // doesn't work in that case, so let it correctly be handled by controller at least we can log + // return true; + } + // don't now how to handle so let it burn ;-) + return false; + }, ready: () => { adapter.subscribeStates('*'); main(); @@ -869,6 +876,7 @@ async function initRpcServer() { daemonURL = `${daemonProto + callbackAddress}:${port}`; try { + // somehow we cannot catch EADDRNOTAVAIL, also not with a cb here rpcServer = rpc.createServer({ host: adapter.config.adapterAddress, port: port @@ -1104,6 +1112,16 @@ async function initRpcServer() { const methods = { event: (err, params) => { + if (err) { + adapter.log.error(`${adapter.config.type}rpc <- received error event: ${err}`); + return ''; + } + + if (!Array.isArray(params)) { + adapter.log.error(`${adapter.config.type}rpc <- Invalid params "${params}" received`); + return ''; + } + adapter.log.debug(`${adapter.config.type}rpc <- event ${JSON.stringify(params)}`); let val; // CUxD ignores all prefixes!! @@ -1117,13 +1135,6 @@ const methods = { } const name = `${params[0]}.${channel}.${params[2]}`; - /* now handled below - if (name === `${adapter.namespace}.CENTRAL.PONG` || name ===`${adapter.namespace}.CENTRAL.0.PONG`) { - adapter.log.debug('PONG event received, ignoring'); - return ''; - } - */ - if (dpTypes[name]) { // it shouldn't be necessary to scale on % values, see https://github.com/ioBroker/ioBroker.hm-rpc/issues/263 // backward compatibility -> max===1 unit===% diff --git a/package-lock.json b/package-lock.json index 147663b7..ed79c478 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "iobroker.hm-rpc", - "version": "1.14.33", + "version": "1.14.34", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 486bbe52..207e874d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iobroker.hm-rpc", - "version": "1.14.33", + "version": "1.14.34", "description": "Connects HomeMatic Interface-Processes (BidCos-Services, Homegear and CUxD) via XML-RPC or BIN-RPC to ioBroker", "author": { "name": "hobbyquaker",