Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

PersistentClient reconnect should subscribe to 'inner client' 'close' event #13

Closed
raintonr opened this issue Mar 13, 2020 · 0 comments
Closed

Comments

@raintonr
Copy link

It seems that sometimes a Chromecast device will disconnect from a client connected with this module.

There is a section of code in PersistentClient that looks like it is designed to cater for such events here:

https://github.com/angelnu/castv2-player/blob/523fd5a8317656a5038b7a7b3ca9d1de4e89f1a7/lib/persistentClient.js#L252

Ie. looks like PersistentClient is supposed to catch any close events and reconnect.

However, the 'client' in this case is not actually a direct 'client' but the a sender class (PlatformSender), which does not actually emit 'close' events and therefore PersistentClient fails to reconnect as I assume it is designed to do.

This manifests itself as issues such as iobroker-community-adapters/ioBroker.chromecast#36

As noted there, a fix is discussed here: thibauts/node-castv2-client#58 (comment), and indeed changing the line referenced above to use the 'inner client' works for me. Ie. change...

            //If connection closes afterwards then re-open it again
            that._client.once("close", function(){
              that._close();
              that._connectClient();
            });

...should be changed to...

            //If connection closes afterwards then re-open it again
            that._client.client.once("close", function(){
              that._close();
              that._connectClient();
            });
Jey-Cee added a commit that referenced this issue Jan 13, 2022
@Jey-Cee Jey-Cee closed this as completed Jan 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants