-
Notifications
You must be signed in to change notification settings - Fork 377
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
Attempting to fix 738 #886
base: master
Are you sure you want to change the base?
Attempting to fix 738 #886
Conversation
I would appreciate some feedback on this. Is there a better approach I could try? Any tips would be appreciated, I'll give it a serious try. |
# When a new cast status is received, give Audible time to load | ||
if status.app_id == "25456794": | ||
self.logger.debug("Detected Audible connection. Sleeping for 1s") | ||
time.sleep(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really OK way to fix a race. Is there another message we can wait for instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure. any ideas you have, or example code you can point me to? i'll try whatever i can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue #738 talks about the Sirius XM app misbehaving, but your comment in the PR talks about Audible. Could you clarify the relationship between the two apps? Or are they the same?
Also, after going through the comments in #738, it's not fully clear to me what pychromecast does which offends the app so much that it terminates, only that adding a delay fixes the problem.
Have you been able to determine how the delay fixes it?
If you run pychromecast with debug enabled, it will dump out all messages sent to and received from the pychromecast, have you done that?
Also, I'm not sure how you've been debugging. But if you want a simple isolated test case, maybe this example script is enough to trigger (and debug) the problem:
python3 -m examples.simple_listener_example --cast 'Living room' --show-debug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, there's already a comment in #738 about using the simple listener example to trigger the problem: #738 (comment)
If you could do that, but with the updated syntax as in my previous comment, both with and without your workaround, that would be really useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git switch master
python3 -m examples.simple_listener_example --cast 'Garage speakers' --show-debug > workspace/master.std.txt 2> workspace/master.err.txt
git switch geoffoxholm:users/geoff/audible_debug
python3 -m examples.simple_listener_example --cast 'Garage speakers' --show-debug > workspace/patch.std.txt 2> workspace/patch.err.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a jump in requestId
in messages sent by pychromecast to the device which I can't explain. We only increment the requestId
when calculating it here:
pychromecast/pychromecast/socket_client.py
Lines 855 to 856 in 449c0b5
request_id = self._gen_request_id() | |
data[REQUEST_ID] = request_id |
Have you removed any lines from the logs?
Edit: Maybe it's ping messages being omitted from the log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be sure, could you change here to log also the pings, both on master and your patch branch, and collect new logs:
pychromecast/pychromecast/socket_client.py
Lines 873 to 882 in 449c0b5
# Log all messages except heartbeat | |
if msg.namespace != NS_HEARTBEAT: | |
self.logger.debug( | |
"[%s(%s):%s] Sending: %s", | |
self.fn or "", | |
self.host, | |
self.port, | |
_message_to_string(msg, data), | |
) | |
pychromecast/pychromecast/socket_client.py
Lines 689 to 697 in 449c0b5
# debug messages | |
if message.namespace != NS_HEARTBEAT: | |
self.logger.debug( | |
"[%s(%s):%s] Received: %s", | |
self.fn or "", | |
self.host, | |
self.port, | |
_message_to_string(message, data), | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git switch master
git pull
# make edits
git diff > workspace/master.diff.txt
python3 -m examples.simple_listener_example --cast 'Garage speakers' --show-debug > workspace/master.std.txt 2> workspace/master.err.txt
master.diff.txt
master.err.txt
master.std.txt
git stash # stash edits
git switch users/geoff/audible_debug
git stash pop # pop edits
git diff master > workspace/branch.diff.txt
python3 -m examples.simple_listener_example --cast 'Garage speakers' --show-debug > workspace/branch.std.txt 2> workspace/branch.err.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue #738 talks about the Sirius XM app misbehaving, but your comment in the PR talks about Audible. Could you clarify the relationship between the two apps? Or are they the same?
They are different apps. In the end the issue with Sirius XM was "fixed" (avoided) when the app was redesigned. It seems the Audible app has a similar pathology to the one that was present in the Sirius XM app, but no longer is.
I'm trying to fix #738.
It looks like some apps (maybe just "Audible" at the moment) have a very rigid interpretation of the connection handshake, and abandon it if messages come out-of-order.
I'd love any feedback to help move this forward. I can step into the debugger, do whatever is needed to figure out how to fix the issue, though I'm new to the
pychromecast
repo.