Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handling timeout properly #44

Open
Ivshti opened this issue Dec 14, 2015 · 7 comments
Open

handling timeout properly #44

Ivshti opened this issue Dec 14, 2015 · 7 comments

Comments

@Ivshti
Copy link

Ivshti commented Dec 14, 2015

Using mafintosh/chromecasts on top of this module, I keep hitting a very serious issue:

When playing a video, then pausing for N minutes, or simply stopping, and then trying to play again, I get "cannot access .send of undefined", since the socket has been closed.

This is OK to some extent, because we have 'close' events which we can handle.

The weird thing is that 'error' never fires (where var client = new castv2.Client()), not on client, nor client.client, nor on player (where client.launch(castv2.DefaultMediaReceiver, function (err, player) { ... }))
It does fire sometimes, a few minutes after the actual close

But how to handle the cases when the connection is closed? A simple reconnect on the same chromecast address does not work - with our without .launch-ing DefaultMediaReceiver. In both cases getStatus keeps returning undefined for status and null as an error.
For whatever reason some state is kept somewhere. Or it requires the .play to be called again.

In any case, I haven't find a robust way to re-initiate the connection like nothing happened.

The heartbeat is working properly, but doesn't seem to be helping.

@dmythro
Copy link

dmythro commented Apr 3, 2016

Got same error recently. And displayed stack trace didn't lead to any of my sources, so not sure even where to check with try ... catch.

Uncaught Exception:
Error: Device timeout
    at HeartbeatController.ontimeout (/app/node_modules/castv2-client/lib/senders/platform.js:56:26)
    at HeartbeatController.g (events.js:260:16)
    at emitNone (events.js:67:13)
    at HeartbeatController.emit (events.js:166:7)
    at ontimeout [as _onTimeout] (/app/node_modules/castv2-client/lib/controllers/heartbeat.js:44:10)
    at Timer.listOnTimeout (timers.js:92:15)

@thibauts
Copy link
Owner

thibauts commented Apr 3, 2016

Can you provide code to reproduce the issue ?

@dmythro
Copy link

dmythro commented Apr 3, 2016

Sure, just pushed code I was playing with to my Chromecast repo.
Probably, you are looking for usage in app/src/services.js.

@dmythro
Copy link

dmythro commented Apr 3, 2016

P.S. I have few questions for the flow to make UX as flawless and automatic as possible, not sure about some cases event handling, would be happy if you'd ping me via email (should be seen in my profile) to solve them and build +/- stable app out there (didn't find your contact).

@thibauts
Copy link
Owner

thibauts commented Apr 3, 2016

I meant something like the minimal code sample that reproduces the issue. I really don't have enough free time to delve through large codebases.

Anyway I did a search on this repo with the error message you got (https://github.com/thibauts/node-castv2-client/search?utf8=%E2%9C%93&q=Device+timeout) which leads straight to the answer you're looking for. You have to listen to error messages emitted by your client, as the sample code in the README shows, and handle the event properly. This may include destroying the client, re-instanciating another one and putting it in the same state.

I suspect this is the problem you all have here. Once timed-out the playing state is lost on the Chromecast itself and solely reconnecting doesn't make it. This probably won't ever be solved in this module, as the code is receiver-agnostic and can't know the process to put a given app in a given state.

I can understand this is frustrating.

If you think I'm mistaken, provide the minimal code that reproduces your issue and simple instructions to run it. I really can't allocate 1~2 hours every time an issue is opened. I don't even have time to work on my current projects. I'm sure you'll understand.

@Z-AX About your UX question, please open an issue and label is as you feel appropriate. I'll try to follow-up. This way it will be simpler and potentially benefit others.

@roccomuso
Copy link

Having the same issue!

@thibauts
Copy link
Owner

My april 3 comment still applies. Please provide a minimal code sample reproducing the issue so we can investigate further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants