question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RTSP/1.0 method SETUP failed with code 520: Origin Error

See original GitHub issue

Describe the bug

Can’t stream anything to Homepod mini, eg tts or radio browser.

Error log

Full log: https://pastebin.com/V4u59p8v

2022-11-25 21:03:23.676 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140291987056976] RTSP/1.0 method SETUP failed with code 520: Origin Error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 943, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/media_player.py", line 292, in async_play_media
    await self.atv.stream.stream_file(media_id)
  File "/usr/local/lib/python3.10/site-packages/pyatv/core/facade.py", line 392, in stream_file
    await self.relay("stream_file")(file, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pyatv/protocols/raop/__init__.py", line 352, in stream_file
    await client.initialize(self.core.service.properties)
  File "/usr/local/lib/python3.10/site-packages/pyatv/protocols/raop/raop.py", line 457, in initialize
    await self._setup_session()
  File "/usr/local/lib/python3.10/site-packages/pyatv/protocols/raop/raop.py", line 486, in _setup_session
    resp = await self.rtsp.setup(
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/rtsp.py", line 181, in setup
    return await self.exchange("SETUP", headers=headers, body=body)
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/rtsp.py", line 265, in exchange
    resp = await self.connection.send_and_receive(
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/http.py", line 414, in send_and_receive
    raise exceptions.HttpError(
pyatv.exceptions.HttpError: RTSP/1.0 method SETUP failed with code 520: Origin Error

How to reproduce the bug?

Go the the apple tv integration in Home Assistant Select the media player entity Browse media Select TTS Google/Microsoft (both don’t work) Keep the sample text and press play

What is expected behavior?

TTS to work 😃

Operating System

Home Assistant Container (docker on Ubuntu)

Python

3.10

pyatv

0.10.3

Device

Homepod mini, 16.1

Additional context

N/A

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
acovacicommented, Nov 27, 2022

I’ve done a bit more digging, using atvremote, and by listing features, I can see that PlayUrl is not supported. On the other hand, I can get it to play using stream_file. Is there a way to change what method the media player uses to cast to homepod?

0reactions
acovacicommented, Nov 30, 2022

Okay so all this thing is a bit over my head, but from what I’m getting, the heartbeat fails.

pyatv/protocols/airplay/remote_control.py:82 - that _failure_func is the only invocation of pyatv.protocols.raop.raop.ControlClient.connection_lost that doesn’t check for None

The last heartbeat I’m seeing isn’t consistent, but it’s in the first 15-ish.

2022-11-29 23:44:18.020 DEBUG (MainThread) [pyatv.core.protocol] Got heartbeat 9 (AirPlay:xxx.xxx.xxx.xxx)

Which empirically makes sense, as I’m hearing a tiny under-half-second-long purr when I hit play. Looking at the logs, I assume the first packet of data had just been sent, then the HomePod sends back the 520. Weird that it works on my Raspberry Pi but not on the Pi inside docker :-?

Anyway, that’s all my tired neuron can figure out for now, hopefully @postlund or one of the other contributors can make sense of this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix "Error 520: Web Server Is Returning an Unknown ...
This problem occurs when your site lacks an HTTP status code or response body. To resolve it, make sure your DNS settings are...
Read more >
Cloudflare Error 520: How to Troubleshoot and Fix It - Hostinger
It may occur either because the origin server is running a resource-intensive script or didn't interpret requests properly. Consequently, the ...
Read more >
Community Tip - Fixing Error 520: Web server is returning an ...
A 520 error occurs when the connection started on the origin web server, but that the request was not completed. The most common...
Read more >
How to Fix Cloudflare Error 520: Web Server is Returning an ...
Cloudflare Error 520 is a server-side diagnostic message indicating that even though a request reached the origin web server, the server ...
Read more >
[Solved] Error 520: Web Server Is Returning an Unknown Error
Empty response from the origin web server that lacks an HTTP status code or response body. Now you know what caused the 520...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found