[GH-ISSUE #464] Setting a custom timeout does not work... #343

Closed
opened 2026-02-27 23:00:17 +03:00 by kerem · 6 comments
Owner

Originally created by @TheWicklowWolf on GitHub (Oct 23, 2023).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/464

Describe the bug
Setting a custom timeout has no effect and I still get ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Also in the docs it states ytm = YTMusic(session=s) however, sessionis incorrect. I think it should be requests_session.

To Reproduce

from ytmusicapi import YTMusic
import requests
import functools
import time

s = requests.Session()
s.request = functools.partial(s.request, timeout=600)
ytmusic = YTMusic(requests_session=s)
search_results = ytmusic.search(query="random", filter="songs", limit=5)
time.sleep(300)
search_results = ytmusic.search(query="random", filter="songs", limit=5)
Originally created by @TheWicklowWolf on GitHub (Oct 23, 2023). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/464 **Describe the bug** Setting a custom timeout has no effect and I still get `('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))` Also in the docs it states `ytm = YTMusic(session=s)` however, `session`is incorrect. I think it should be `requests_session`. **To Reproduce** ``` from ytmusicapi import YTMusic import requests import functools import time s = requests.Session() s.request = functools.partial(s.request, timeout=600) ytmusic = YTMusic(requests_session=s) search_results = ytmusic.search(query="random", filter="songs", limit=5) time.sleep(300) search_results = ytmusic.search(query="random", filter="songs", limit=5) ```
kerem 2026-02-27 23:00:17 +03:00
Author
Owner

@sigma67 commented on GitHub (Oct 24, 2023):

Is your error even timeout related? It basically just takes your session and uses it:

github.com/sigma67/ytmusicapi@05a5fb8153/ytmusicapi/ytmusic.py (L76-L77)

Where did you see the wrong part in the docs? Please provide a link

<!-- gh-comment-id:1776649002 --> @sigma67 commented on GitHub (Oct 24, 2023): Is your error even timeout related? It basically just takes your session and uses it: https://github.com/sigma67/ytmusicapi/blob/05a5fb81533089716ce38516dafcdda50c606917/ytmusicapi/ytmusic.py#L76-L77 Where did you see the wrong part in the docs? Please provide a link
Author
Owner
<!-- gh-comment-id:1777013421 --> @TheWicklowWolf commented on GitHub (Oct 24, 2023): Here: https://github.com/sigma67/ytmusicapi/blob/05a5fb81533089716ce38516dafcdda50c606917/ytmusicapi/ytmusic.py#L53-L55 And subsequently: https://ytmusicapi.readthedocs.io/en/latest/reference.html#ytmusicapi.YTMusic.__init__
Author
Owner

@TheWicklowWolf commented on GitHub (Oct 24, 2023):

Is your error even timeout related? It basically just takes your session and uses it:

I'm not sure, I thought if I set the session timeout then the connection should still be open. Maybe not, what else could cause this error?

Exception has occurred: ConnectionError
('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Great library by the way 👍

<!-- gh-comment-id:1777021536 --> @TheWicklowWolf commented on GitHub (Oct 24, 2023): > Is your error even timeout related? It basically just takes your session and uses it: I'm not sure, I thought if I set the session timeout then the connection should still be open. Maybe not, what else could cause this error? ``` Exception has occurred: ConnectionError ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) http.client.RemoteDisconnected: Remote end closed connection without response During handling of the above exception, another exception occurred: urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) ``` Great library by the way 👍
Author
Owner

@sigma67 commented on GitHub (Oct 24, 2023):

Good catch on the docs issue.

Here's some info on your error: https://stackoverflow.com/questions/61303351/why-does-requests-session-get-raise-an-requests-exceptions-connectionerror-in

It's not an issue with the ytmusicapi implementation, you'll need to handle the error on your end

<!-- gh-comment-id:1777044860 --> @sigma67 commented on GitHub (Oct 24, 2023): Good catch on the docs issue. Here's some info on your error: https://stackoverflow.com/questions/61303351/why-does-requests-session-get-raise-an-requests-exceptions-connectionerror-in It's not an issue with the ytmusicapi implementation, you'll need to handle the error on your end
Author
Owner

@sigma67 commented on GitHub (Oct 24, 2023):

Feel free to submit a PR if you want

<!-- gh-comment-id:1777046003 --> @sigma67 commented on GitHub (Oct 24, 2023): Feel free to submit a PR if you want
Author
Owner

@TheWicklowWolf commented on GitHub (Oct 24, 2023):

It's not an issue with the ytmusicapi implementation, you'll need to handle the error on your end

Ok, thanks for the clarification!

<!-- gh-comment-id:1777130319 --> @TheWicklowWolf commented on GitHub (Oct 24, 2023): > It's not an issue with the ytmusicapi implementation, you'll need to handle the error on your end Ok, thanks for the clarification!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#343
No description provided.