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.

Mopidy as a streaming target

See original GitHub issue

I know mopidy is not a supported target, but I’d like to understand what could be the issue, here. To be clear, this is about streaming to mopidy, not supporting the library side.

The key error on mopidy seems to be

ERROR    2022-06-18 14:09:26,433 [1:Core-10] mopidy.core.playback
  StreamBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 697, in _update_chunk_length
    self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''

Is MASS using a special protocol that has to be understood by mopidy?

Full HA log

2022-06-18 14:09:25 INFO (MainThread) [music_assistant.players.stream] Start Streaming queue track: database://track/1520 (Agnes Obel - The Curse) for queue Mopidy Uranus
2022-06-18 14:09:26 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 167, in serve_queue_stream
    await queue_stream.subscribe(client_id, resp.write)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 317, in subscribe
    assert not self.done.is_set(), "Stream task is already finished"
AssertionError: Stream task is already finished
2022-06-18 14:09:26 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 167, in serve_queue_stream
    await queue_stream.subscribe(client_id, resp.write)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 317, in subscribe
    assert not self.done.is_set(), "Stream task is already finished"
AssertionError: Stream task is already finished
2022-06-18 14:09:27 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 167, in serve_queue_stream
    await queue_stream.subscribe(client_id, resp.write)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 317, in subscribe
    assert not self.done.is_set(), "Stream task is already finished"
AssertionError: Stream task is already finished
2022-06-18 14:09:27 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 167, in serve_queue_stream
    await queue_stream.subscribe(client_id, resp.write)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 317, in subscribe
    assert not self.done.is_set(), "Stream task is already finished"
AssertionError: Stream task is already finished
2022-06-18 14:09:27 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 167, in serve_queue_stream
    await queue_stream.subscribe(client_id, resp.write)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 317, in subscribe
    assert not self.done.is_set(), "Stream task is already finished"
AssertionError: Stream task is already finished
2022-06-18 14:09:27 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 167, in serve_queue_stream
    await queue_stream.subscribe(client_id, resp.write)
  File "/usr/local/lib/python3.9/site-packages/music_assistant/controllers/streams.py", line 317, in subscribe
    assert not self.done.is_set(), "Stream task is already finished"
AssertionError: Stream task is already finished

Full mopidy log

ERROR    2022-06-18 14:09:26,433 [1:Core-10] mopidy.core.playback
  StreamBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 697, in _update_chunk_length
    self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 438, in _error_catcher
    yield
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 764, in read_chunked
    self._update_chunk_length()
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 701, in _update_chunk_length
    raise InvalidChunkLength(self, line)
urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/models.py", line 750, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 572, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 793, in read_chunked
    self._original_response.close()
  File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 455, in _error_catcher
    raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mopidy/core/playback.py", line 350, in _change
    if not backend.playback.change_track(pending_tl_track.track).get():
  File "/usr/lib/python3/dist-packages/pykka/_threading.py", line 45, in get
    _compat.reraise(*self._data['exc_info'])
  File "/usr/lib/python3/dist-packages/pykka/_compat/__init__.py", line 29, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 193, in _actor_loop
    response = self._handle_receive(envelope.message)
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 299, in _handle_receive
    return callee(*message.args, **message.kwargs)
  File "/usr/lib/python3/dist-packages/mopidy/backend.py", line 313, in change_track
    uri = self.translate_uri(track.uri)
  File "/usr/lib/python3/dist-packages/mopidy/stream/actor.py", line 93, in translate_uri
    unwrapped_uri, _ = _unwrap_stream(
  File "/usr/lib/python3/dist-packages/mopidy/stream/actor.py", line 163, in _unwrap_stream
    content = http.download(
  File "/usr/lib/python3/dist-packages/mopidy/internal/http.py", line 42, in download
    for chunk in response.iter_content(chunk_size):
  File "/usr/lib/python3/dist-packages/requests/models.py", line 753, in generate
    raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))
WARNING  2022-06-18 14:09:26,454 [1:Core-10] mopidy.core.tracklist
  Track is not playable: http://192.168.3.252:8095/374d38f3a092465897d9da4b945b6ca1.flac
ERROR    2022-06-18 14:09:27,422 [1:Core-10] mopidy.core.library
  StreamBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 697, in _update_chunk_length
    self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 438, in _error_catcher
    yield
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 764, in read_chunked
    self._update_chunk_length()
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 701, in _update_chunk_length
    raise InvalidChunkLength(self, line)
urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/models.py", line 750, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 572, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 793, in read_chunked
    self._original_response.close()
  File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 455, in _error_catcher
    raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mopidy/core/library.py", line 17, in _backend_error_handling
    yield
  File "/usr/lib/python3/dist-packages/mopidy/core/library.py", line 217, in lookup
    result = future.get()
  File "/usr/lib/python3/dist-packages/pykka/_threading.py", line 45, in get
    _compat.reraise(*self._data['exc_info'])
  File "/usr/lib/python3/dist-packages/pykka/_compat/__init__.py", line 29, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 193, in _actor_loop
    response = self._handle_receive(envelope.message)
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 299, in _handle_receive
    return callee(*message.args, **message.kwargs)
  File "/usr/lib/python3/dist-packages/mopidy/stream/actor.py", line 66, in lookup
    _, scan_result = _unwrap_stream(
  File "/usr/lib/python3/dist-packages/mopidy/stream/actor.py", line 163, in _unwrap_stream
    content = http.download(
  File "/usr/lib/python3/dist-packages/mopidy/internal/http.py", line 42, in download
    for chunk in response.iter_content(chunk_size):
  File "/usr/lib/python3/dist-packages/requests/models.py", line 753, in generate
    raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))
ERROR    2022-06-18 14:09:27,554 [1:Core-10] mopidy.core.library
  StreamBackend backend caused an exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 697, in _update_chunk_length
    self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 438, in _error_catcher
    yield
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 764, in read_chunked
    self._update_chunk_length()
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 701, in _update_chunk_length
    raise InvalidChunkLength(self, line)
urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/models.py", line 750, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 572, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 793, in read_chunked
    self._original_response.close()
  File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.8/dist-packages/urllib3/response.py", line 455, in _error_catcher
    raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mopidy/core/library.py", line 17, in _backend_error_handling
    yield
  File "/usr/lib/python3/dist-packages/mopidy/core/library.py", line 217, in lookup
    result = future.get()
  File "/usr/lib/python3/dist-packages/pykka/_threading.py", line 45, in get
    _compat.reraise(*self._data['exc_info'])
  File "/usr/lib/python3/dist-packages/pykka/_compat/__init__.py", line 29, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 193, in _actor_loop
    response = self._handle_receive(envelope.message)
  File "/usr/lib/python3/dist-packages/pykka/_actor.py", line 299, in _handle_receive
    return callee(*message.args, **message.kwargs)
  File "/usr/lib/python3/dist-packages/mopidy/stream/actor.py", line 66, in lookup
    _, scan_result = _unwrap_stream(
  File "/usr/lib/python3/dist-packages/mopidy/stream/actor.py", line 163, in _unwrap_stream
    content = http.download(
  File "/usr/lib/python3/dist-packages/mopidy/internal/http.py", line 42, in download
    for chunk in response.iter_content(chunk_size):
  File "/usr/lib/python3/dist-packages/requests/models.py", line 753, in generate
    raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
koyingcommented, Jun 18, 2022

Yeah, I saw the OSMC issue but was not sure it was actually the same issue. Will test the forthcoming point release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mopidy-Stream — Mopidy 3.4.1-1-g47d506b6 documentation
Mopidy -Stream is an extension for playing streaming music. It is bundled with Mopidy and enabled by default. This backend does not provide...
Read more >
Mopidy-TuneIn 0.4.1 - PyPI
Mopidy extension for playing music from TuneIn.
Read more >
Build your multi-room and multi-provider sound ... - Platypush
Configure the [audio] section of your mopidy.conf file to stream to the Snapcast FIFO (note: with this configuration Mopidy will only stream ......
Read more >
Media Player platform for Mopidy - Custom Integrations
I created a Mopidy platform integration for media_player, ... snapshot of the current playlist - service: mopidy.snapshot target: entity_id: ...
Read more >
My music setup at home with mopidy, forked-daapd and ...
Mopidy connects to forked-daapd that then streams to any AirPlay devices to multiple rooms in my house. Im pretty happy with this setup...
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