dufourgilles / node-emberplus

Lawo EmberPlus protocol client and server
MIT License
19 stars 6 forks source link

UnhandledPromiseRejectionWarning #8

Closed dewiweb closed 4 years ago

dewiweb commented 4 years ago

Hello, I'm looking for communicate and interact with a LAWO console with your example:

const EmberClient = require('node-emberplus').EmberClient;
const client = new EmberClient("192.168.100.36", 9000);

client.on("error", e => {
   console.log(e);
});
client.connect()
   // Get Root info
   .then(() => client.getDirectory())
   // Get a Specific Node
   .then(() => client.getElementByPath("_2"))
   .then(node => {
      console.log(node);
   })

I'm able to have a result for the first level nodes of the tree, but when I want to interact with another node in a sublevel like this:

const EmberClient = require('node-emberplus').EmberClient;
const client = new EmberClient("192.168.100.36", 9000);

client.on("error", e => {
   console.log(e);
});
client.connect()
   // Get Root info
   .then(() => client.getDirectory())
   // Get a Specific Node
   .then(() => client.getElementByPath("_2/_7"))
   .then(node => {
      console.log(node);
   })

I've got this issue:

(node:21195) UnhandledPromiseRejectionWarning: Error: Request 1 - 25030 timed out
    at EmberClient._makeRequest (/home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:103:48)
    at EmberClient.addRequest (/home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:123:14)
    at /home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:305:18
    at new Promise (<anonymous>)
    at EmberClient.getDirectory (/home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:304:16)
    at /home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:437:29
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
(node:21195) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21195) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
dewiweb commented 4 years ago

Apparently Lawo MC console send periodically keep-alive request. Is Keep-alive response implemented in node-emberplus client?

vashat commented 4 years ago

I'm having the exact same problem when trying to connect to a Lawo MC console. First level node works, but next level will not. Getting that time out error as well.

(node:30347) UnhandledPromiseRejectionWarning: Error: Request 1 - 2 timed out at EmberClient._makeRequest (/Users/vashat/scripts/emberplus/node_modules/node-emberplus/EmberClient/EmberClient.js:103:48) at EmberClient.addRequest (/Users/vashat/scripts/emberplus/node_modules/node-emberplus/EmberClient/EmberClient.js:123:14) at /Users/vashat/scripts/emberplus/node_modules/node-emberplus/EmberClient/EmberClient.js:305:18 at new Promise (<anonymous>) at EmberClient.getDirectory (/Users/vashat/scripts/emberplus/node_modules/node-emberplus/EmberClient/EmberClient.js:304:16) at /Users/vashat/scripts/emberplus/node_modules/node-emberplus/EmberClient/EmberClient.js:437:29 at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:30347) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:30347) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

nepbenonions commented 4 years ago

Hello, I'm looking for communicate and interact with a LAWO console with your example:

const EmberClient = require('node-emberplus').EmberClient;
const client = new EmberClient("192.168.100.36", 9000);

client.on("error", e => {
   console.log(e);
});
client.connect()
   // Get Root info
   .then(() => client.getDirectory())
   // Get a Specific Node
   .then(() => client.getElementByPath("_2"))
   .then(node => {
      console.log(node);
   })

I'm able to have a result for the first level nodes of the tree, but when I want to interact with another node in a sublevel like this:

const EmberClient = require('node-emberplus').EmberClient;
const client = new EmberClient("192.168.100.36", 9000);

client.on("error", e => {
   console.log(e);
});
client.connect()
   // Get Root info
   .then(() => client.getDirectory())
   // Get a Specific Node
   .then(() => client.getElementByPath("_2/_7"))
   .then(node => {
      console.log(node);
   })

I've got this issue:

(node:21195) UnhandledPromiseRejectionWarning: Error: Request 1 - 25030 timed out
    at EmberClient._makeRequest (/home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:103:48)
    at EmberClient.addRequest (/home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:123:14)
    at /home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:305:18
    at new Promise (<anonymous>)
    at EmberClient.getDirectory (/home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:304:16)
    at /home/regie/AppLawo/node_modules/node-emberplus/EmberClient/EmberClient.js:437:29
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
(node:21195) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:21195) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Hey, I think this issue is more to do with how Lawo have chosen to assign identifiers in the tree.

Multiple elements in the tree have "_1" as the identifier, for example straight under the root node there is "devices" which has identifier "_1", then there is "Channels/Inputs" which you are trying to reach which is "_2/_1".

I did some digging by bypassing the timeout function and it looks like the getElementsByPath function seems to see "_1", assumes you are referring to "Root/Devices" and actually returns "Devices" in an infinite loop, hence the time out.

dufourgilles commented 4 years ago

Should work with 2.5.6

gdufour@gdnet2:/mnt/raid/Node/emberplus$ node mon.js connected Node { _parent: QualifiedNode { _parent: TreeNode { _parent: null, _subscribers: Set {}, elements: [Map] }, _subscribers: Set {}, path: '17166', _seqID: 106, contents: NodeContents { isOnline: true, identifier: '_2', description: 'Channels' }, elements: Map { 17167 => [Node], 303498 => [Node], 303837 => [Node], 331120 => [Node], 340433 => [Node], 351298 => [Node], 374595 => [Circular], 421188 => [Node], 423597 => [Node], 423598 => [Node], 513039 => [Node] } }, _subscribers: Set {}, number: 374595, _seqID: 99, contents: NodeContents { isOnline: true, identifier: '_7', description: 'GP Channels' } } done