Aietes / node-red-contrib-harmony

Node-RED integration for Harmony hub
MIT License
15 stars 18 forks source link

"TypeError: Cannot read property 'startActivity' of undefined" #2

Closed dgmltn closed 6 years ago

dgmltn commented 7 years ago

After a while (?) my H activity node stops working properly. The hub will search for and find the hub right away, but the activity starts displaying a number instead of the the activity name. The activity search button says "loading activities..." forever, and then when the start activity is triggered, I get this error:

msg : error "TypeError: Cannot read property 'startActivity' of undefined"

Aietes commented 7 years ago

It sounds like this happens because your Harmony Hub changed its IP. Can you post the more detailed error message with the line number here?

dgmltn commented 7 years ago

Ok, I'll pay more attention to the IP Address. I'll also try setting a static IP address in my router. Could this happen if the IP address lease expires, even if the address does not change?

How would I find the more detailed error message in the context of Node-RED?

dgmltn commented 7 years ago

Well, it happened again, and the IP address is still the same. I haven't been able to find any logs or detailed stack trace about the error.

strelniece commented 7 years ago

Sounds like sort of the same problem as I have.

Sometimes it works, and sometimes not... :)

node-red-log gives

errorhub { Error: MAX_CLIENTS=6 at Connection.onStanza (/home/pi/.node-red/node_modules/node-xmpp-core/lib/Connection.js:355:17) at StreamParser. (/home/pi/.node-red/node_modules/node-xmpp-core/lib/Connection.js:226:10) at emitOne (events.js:96:13) at StreamParser.emit (events.js:188:7) at SaxLtx. (/home/pi/.node-red/node_modules/node-xmpp-core/lib/StreamParser.js:58:14) at emitOne (events.js:96:13) at SaxLtx.emit (events.js:188:7) at SaxLtx._handleTagOpening (/home/pi/.node-red/node_modules/ltx/lib/parsers/ltx.js:31:18) at SaxLtx.write (/home/pi/.node-red/node_modules/ltx/lib/parsers/ltx.js:105:26) at StreamParser.write (/home/pi/.node-red/node_modules/node-xmpp-core/lib/StreamParser.js:123:17) at Connection.onData (/home/pi/.node-red/node_modules/node-xmpp-core/lib/Connection.js:305:17) at emitOne (events.js:101:20) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:548:20) stanza: Stanza { name: 'stream:error', parent: null, children: [ [Object], [Object] ], attrs: { 'xmlns:stream': 'http://etherx.jabber.org/streams' } } }

dgmltn commented 7 years ago

I think it is a reconnect issue, it becomes disconnected after a while and then does not properly reconnect.

@strelniece your bug is mentioned in the underlying harmony library: https://github.com/swissmanu/harmonyhubjs-client/issues/34

And my issue is mentioned too: https://github.com/swissmanu/harmonyhubjs-client/issues/31

strelniece commented 7 years ago

Let's hope it will be a fix soooooon

dgmltn commented 7 years ago

I think some sort of reconnection strategy is in order... Whether that's done in node-red-contrib-harmony or harmonyhubjs-client though is up for debate ... @aietes do you have any thoughts?

Aietes commented 7 years ago

I'm just back from vacation, I'll look into it an implement an automatic reconnection soon, hopefully I can release it this week.

Aietes commented 7 years ago

I can't really solve the issue, as it needs to be addressed in the underlying library. I pushed a new version 1.0.6 with a reconnect on timeout, can you please try if this helps mitigate the problem?

dgmltn commented 7 years ago

Thanks a lot for the help. Just upgraded to 1.0.6, :crossed_fingers:

Aietes commented 7 years ago

Does it work for you guys? I couldn't reproduce the error, so I have to rely on you for testing :)

dgmltn commented 7 years ago

I installed it but didn't get the chance to test it thoroughly yet. The error occurs after a day or so, for me.

dgmltn commented 7 years ago

No, I'm still seeing the same error message, "TypeError: Cannot read property 'startActivity' of undefined"

dgmltn commented 7 years ago

When this happens, also I cannot look up the activity name for the integer activity anymore on the Node RED UI. I see "Loading activities..." forever after clicking the magnifying glass.

Aietes commented 7 years ago

I just fixed another bug that appeared after deploying nodes a couple of times. Possibly your problem was related to the same bug. I would appreciate if you can give this new version 1.0.7 a try.

dgmltn commented 7 years ago

Thanks for the update! I just npm update'd this module, so far it works great, but my problem came after a duration of time. I won't have access to this computer for a week so I will try it when I get back!

dgmltn commented 7 years ago

I did see this in the logs just now, but the rules are still working:

Disconnected from Harmony Hub: Error: Timed out after 50000 ms

dgmltn commented 7 years ago

Well, I waited a bit longer and now got the same error message when trying to "PowerOff". But I did catch this more detailed error message in the log:

31 Mar 01:14:50 - [error] [H activity:Power Off TV] TypeError: Cannot read property 'startActivity' of undefined
errorhub { Error: MAX_CLIENTS=6
at Connection.onStanza (/home/doug/.node-red/node_modules/node-xmpp-core/lib/Connection.js:355:17)
at StreamParser.<anonymous> (/home/doug/.node-red/node_modules/node-xmpp-core/lib/Connection.js:226:10)
at emitOne (events.js:96:13)
at StreamParser.emit (events.js:188:7)
at SaxLtx.<anonymous> (/home/doug/.node-red/node_modules/node-xmpp-core/lib/StreamParser.js:58:14)
at emitOne (events.js:96:13)
at SaxLtx.emit (events.js:188:7)
at SaxLtx._handleTagOpening (/home/doug/.node-red/node_modules/ltx/lib/parsers/ltx.js:31:18)
at SaxLtx.write (/home/doug/.node-red/node_modules/ltx/lib/parsers/ltx.js:105:26)
at StreamParser.write (/home/doug/.node-red/node_modules/node-xmpp-core/lib/StreamParser.js:123:17)
at Connection.onData (/home/doug/.node-red/node_modules/node-xmpp-core/lib/Connection.js:305:17)
at emitOne (events.js:101:20)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:548:20)
stanza:
Stanza {
name: 'stream:error',
parent: null,
children: [ [Object], [Object] ],
attrs: { 'xmlns:stream': 'http://etherx.jabber.org/streams' } } }