Skip to content

Add timeout to HTTP requests#422

Merged
mcarlton00 merged 3 commits into
jellyfin:masterfrom
rcorex:fix-http-timeout
May 21, 2026
Merged

Add timeout to HTTP requests#422
mcarlton00 merged 3 commits into
jellyfin:masterfrom
rcorex:fix-http-timeout

Conversation

@rcorex

@rcorex rcorex commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Added timeout parameter to GET, POST, and DELETE requests to improve resiliency and prevent UI hangs.

The most important change is to the POST request which is used to update playback state. If this POST request has no response with no timeout value, the Kodi video player UI will become unresponsive.

In Kodi, Jellycon hooks into the seek callback which is synchronous. So after a seek, if the Jellycon POST request to update playback state hangs, then the Kodi player UI will also hang.

Added timeout parameter to GET, POST, and DELETE requests to improve resiliency and prevent UI hangs.

The most important change is for the POST request which is used to update playback state. If this POST request has no response with no timeout value, the Kodi video player UI will become unresponsive.
Comment thread resources/lib/jellyfin.py Outdated

r = requests.get(url, headers=self.headers, verify=self.verify_cert)
try:
r = requests.get(url, headers=self.headers, verify=self.verify_cert, timeout=5)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have doubts that a 5 second timeout is enough for get requests. I've seen some calls (like music in the 10.11 release cycle) take upwards of 30. That's admittedly an outlier and is because the server has problems, but knowing how large some libraries get and how much data has to get processed for the api response, 5 seconds seems very short.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about changing the timeout to (5, 60) - 5s connect timeout and 60s read timeout. is that okay or do you suggest other values? should it be changed for the post and delete requests also?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would imagine 60s read for GET is sufficient. I don't think there's any real concern for posts and deletes needing anything extra

Comment thread resources/lib/jellyfin.py Fixed
rcorex added 2 commits May 3, 2026 21:14
change timeout for get request to 5s connection timeout and 60s read timeout.

changed except: to except Exception: for delete request, to avoid catching system exceptions.
Changed except: to except Exception: so that it doesn't catch system exceptions from BaseException, which could cause unintended stalling.
@mcarlton00 mcarlton00 added the bug Something isn't working label May 21, 2026
Comment thread resources/lib/jellyfin.py
requests.delete(url, headers=self.headers, verify=self.verify_cert)
try:
requests.delete(url, headers=self.headers, verify=self.verify_cert, timeout=5)
except Exception:
@mcarlton00
mcarlton00 merged commit 16f782d into jellyfin:master May 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants