[GH-ISSUE #171] HTTP2 support #354

Closed
opened 2026-03-15 03:07:22 +03:00 by kerem · 16 comments
Owner

Originally created by @SeyfSV on GitHub (Sep 9, 2019).
Original GitHub issue: https://github.com/asapach/peerflix-server/issues/171

Hi,
I tried to use peerflix-server with Kodi through my custom addon, but I got an issue with current Kodi version 18.* - it uses HTTP2 protocol for getting video files and nodejs http does not has mechanisms to fallback to HTTP.
Do you plan to add support for HTTP2?

Originally created by @SeyfSV on GitHub (Sep 9, 2019). Original GitHub issue: https://github.com/asapach/peerflix-server/issues/171 Hi, I tried to use peerflix-server with Kodi through my custom addon, but I got an issue with current Kodi version 18.* - it uses HTTP2 protocol for getting video files and nodejs http does not has mechanisms to fallback to HTTP. Do you plan to add support for HTTP2?
kerem closed this issue 2026-03-15 03:07:31 +03:00
Author
Owner

@asapach commented on GitHub (Sep 9, 2019):

A PR is welcome.

Does Kodi require TLS? https://en.wikipedia.org/wiki/HTTP/2#Encryption

<!-- gh-comment-id:529419744 --> @asapach commented on GitHub (Sep 9, 2019): A PR is welcome. Does Kodi require TLS? https://en.wikipedia.org/wiki/HTTP/2#Encryption
Author
Owner

@SeyfSV commented on GitHub (Sep 9, 2019):

I do not think so.
Kodi uses CURL library for sending such requests. In previous version CURLOPT_HTTP_VERSION was CURL_HTTP_VERSION_1_1, and now CURL_HTTP_VERSION_2_0.
When I provide URL from peerflix-server (non TLS) it does not return errors. It sends request, but nodejs does not response to it.
You can check this behaviour by calling perflix-server from curl with --http2 key.

<!-- gh-comment-id:529426436 --> @SeyfSV commented on GitHub (Sep 9, 2019): I do not think so. Kodi uses CURL library for sending such requests. In previous version CURLOPT_HTTP_VERSION was CURL_HTTP_VERSION_1_1, and now CURL_HTTP_VERSION_2_0. When I provide URL from peerflix-server (non TLS) it does not return errors. It sends request, but nodejs does not response to it. You can check this behaviour by calling perflix-server from curl with --http2 key.
Author
Owner

@htpcforall commented on GitHub (Sep 10, 2019):

Hi SeyfSV,
I have developed an add-on in kodi to stream torrents from my server running Peerflix. Working great. Although I'm using Krypton and Jarvis. Haven't tried 18. How are you implementing the torrent streaming process? Maybe I can help. Jay

<!-- gh-comment-id:529880815 --> @htpcforall commented on GitHub (Sep 10, 2019): Hi SeyfSV, I have developed an add-on in kodi to stream torrents from my server running Peerflix. Working great. Although I'm using Krypton and Jarvis. Haven't tried 18. How are you implementing the torrent streaming process? Maybe I can help. Jay
Author
Owner

@ghost commented on GitHub (Sep 10, 2019):

Pretty simple: https://github.com/asapach/peerflix-server/compare/master...pro-src:spdy?expand=1

<!-- gh-comment-id:529910094 --> @ghost commented on GitHub (Sep 10, 2019): Pretty simple: https://github.com/asapach/peerflix-server/compare/master...pro-src:spdy?expand=1
Author
Owner

@SeyfSV commented on GitHub (Sep 10, 2019):

Hi SeyfSV,
I have developed an add-on in kodi to stream torrents from my server running Peerflix. Working great. Although I'm using Krypton and Jarvis. Haven't tried 18. How are you implementing the torrent streaming process? Maybe I can help. Jay

Hi, @htpcforall ,
Yes, you are right, with previous version all working great, but Kodi 18 use HTTP2 by default.
I just put link from /torrents/{infoHash} response to Player.play() function.

<!-- gh-comment-id:529982499 --> @SeyfSV commented on GitHub (Sep 10, 2019): > Hi SeyfSV, > I have developed an add-on in kodi to stream torrents from my server running Peerflix. Working great. Although I'm using Krypton and Jarvis. Haven't tried 18. How are you implementing the torrent streaming process? Maybe I can help. Jay Hi, @htpcforall , Yes, you are right, with previous version all working great, but Kodi 18 use HTTP2 by default. I just put `link` from /torrents/{infoHash} response to `Player.play()` function.
Author
Owner

@SeyfSV commented on GitHub (Sep 10, 2019):

Pretty simple: https://github.com/asapach/peerflix-server/compare/master...pro-src:spdy?expand=1

Hi, @pro-src ,
I checked you code, it does not work :(
Browser says "The connection was reset".
CURL returns curl: (52) Empty reply from server on both http1.1 and http2 calls.

<!-- gh-comment-id:530009153 --> @SeyfSV commented on GitHub (Sep 10, 2019): > Pretty simple: https://github.com/asapach/peerflix-server/compare/master...pro-src:spdy?expand=1 Hi, @pro-src , I checked you code, it does not work :( Browser says "The connection was reset". CURL returns `curl: (52) Empty reply from server` on both http1.1 and http2 calls.
Author
Owner

@ghost commented on GitHub (Sep 10, 2019):

@SeyfSV Fixed, I forgot to nest the options. I don't actually need this so I didn't test. :P

<!-- gh-comment-id:530028549 --> @ghost commented on GitHub (Sep 10, 2019): @SeyfSV Fixed, I forgot to nest the options. I don't actually need this so I didn't test. :P
Author
Owner

@SeyfSV commented on GitHub (Sep 10, 2019):

@SeyfSV Fixed, I forgot to nest the options. I don't actually need this so I didn't test. :P

@pro-src HTTP2 still does not work.

curl http://localhost:9000/torrents --http2 -v
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9000 (#0)
> GET /torrents HTTP/1.1
> Host: localhost:9000
> User-Agent: curl/7.58.0
> Accept: */*
> Connection: Upgrade, HTTP2-Settings
> Upgrade: h2c
> HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA
> 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server

<!-- gh-comment-id:530085283 --> @SeyfSV commented on GitHub (Sep 10, 2019): > @SeyfSV Fixed, I forgot to nest the options. I don't actually need this so I didn't test. :P @pro-src HTTP2 still does not work. ``` curl http://localhost:9000/torrents --http2 -v * Trying 127.0.0.1... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 9000 (#0) > GET /torrents HTTP/1.1 > Host: localhost:9000 > User-Agent: curl/7.58.0 > Accept: */* > Connection: Upgrade, HTTP2-Settings > Upgrade: h2c > HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA > * Empty reply from server * Connection #0 to host localhost left intact curl: (52) Empty reply from server ```
Author
Owner

@ghost commented on GitHub (Sep 10, 2019):

Hmm... Maybe I spoke too soon. I'll let you know once I've had a chance to test this myself.

<!-- gh-comment-id:530086496 --> @ghost commented on GitHub (Sep 10, 2019): Hmm... Maybe I spoke too soon. I'll let you know once I've had a chance to test this myself.
Author
Owner

@ghost commented on GitHub (Sep 11, 2019):

Ideally, this patch should just work (based on docs) but it seems like everything http2 in Node.js land is currently unstable. I'm sure there are workarounds but I don't actually intend on sending a PR for this, sorry, not that interested. So until express creates a compatibility layer around the builtin http2 request/response objects, I would leave this alone. Kodi is really to blame here, it should fallback to http/1.

Also note that the dependencies are outdated. Updating the dependencies is pretty simple when using npm-check-updates:

rm -f yarn.lock package-lock.json
yarn global add npm-check-updates # npm i -g npm-check-updates
ncu -u
yarn install --production # npm i --production
yarn audit # npm audit

You'll hit an error though, due to some middlewares no longer being shipped with express:

yarn add morgan --production # npm i --save morgan --production

Replace: express.logger('dev') -> require('morgan')('dev') in server/bin.js

If you don't won't to work on this unstable area, maybe attempt to use a http2 proxy.

Good luck 😄

<!-- gh-comment-id:530225068 --> @ghost commented on GitHub (Sep 11, 2019): Ideally, this patch should just work (based on docs) but it seems like everything http2 in Node.js land is currently unstable. I'm sure there are workarounds but I don't actually intend on sending a PR for this, sorry, not that interested. So until express creates a compatibility layer around the builtin http2 request/response objects, I would leave this alone. Kodi is really to blame here, it should fallback to http/1. Also note that the dependencies are outdated. Updating the dependencies is pretty simple when using `npm-check-updates`: ```sh rm -f yarn.lock package-lock.json yarn global add npm-check-updates # npm i -g npm-check-updates ncu -u yarn install --production # npm i --production yarn audit # npm audit ``` You'll hit an error though, due to some middlewares no longer being shipped with express: ```sh yarn add morgan --production # npm i --save morgan --production ``` Replace: `express.logger('dev')` -> `require('morgan')('dev')` in server/bin.js If you don't won't to work on this unstable area, maybe attempt to use a http2 proxy. Good luck :smile:
Author
Owner

@SeyfSV commented on GitHub (Sep 11, 2019):

@pro-src , I totally agree with you about fallback to http/1.
And we are not alone: https://github.com/xbmc/xbmc/pull/16601

@asapach , I'll close this issue. Thnx!

<!-- gh-comment-id:530469907 --> @SeyfSV commented on GitHub (Sep 11, 2019): @pro-src , I totally agree with you about fallback to http/1. And we are not alone: https://github.com/xbmc/xbmc/pull/16601 @asapach , I'll close this issue. Thnx!
Author
Owner

@htpcforall commented on GitHub (Sep 13, 2019):

Hi SeyfSV,
I have developed an add-on in kodi to stream torrents from my server running Peerflix. Working great. Although I'm using Krypton and Jarvis. Haven't tried 18. How are you implementing the torrent streaming process? Maybe I can help. Jay

Hi, @htpcforall ,
Yes, you are right, with previous version all working great, but Kodi 18 use HTTP2 by default.
I just put link from /torrents/{infoHash} response to Player.play() function.

@SeyfSV Any chance I can test your add-on? Honestly, I'm would like to see how you implemented peerflix-server. I'm hungry for any knowledge around this a I would like to improve my add-ons functionality as much as possible. I would like to see if there's a way to solve the http2 issue as well. Hope to hear back. Thanks.

<!-- gh-comment-id:531289433 --> @htpcforall commented on GitHub (Sep 13, 2019): > > Hi SeyfSV, > > I have developed an add-on in kodi to stream torrents from my server running Peerflix. Working great. Although I'm using Krypton and Jarvis. Haven't tried 18. How are you implementing the torrent streaming process? Maybe I can help. Jay > > Hi, @htpcforall , > Yes, you are right, with previous version all working great, but Kodi 18 use HTTP2 by default. > I just put `link` from /torrents/{infoHash} response to `Player.play()` function. @SeyfSV Any chance I can test your add-on? Honestly, I'm would like to see how you implemented peerflix-server. I'm hungry for any knowledge around this a I would like to improve my add-ons functionality as much as possible. I would like to see if there's a way to solve the http2 issue as well. Hope to hear back. Thanks.
Author
Owner

@SeyfSV commented on GitHub (Oct 4, 2019):

For info: http module supports http2 requests. Issue occurs in socket.io module, that intercepts Upgrade: h2c header and brokes connection.
As workaround I create socket Object only with transports: 'pooling' option. Yes, it disables WebSocket, but it is not critical for me.

<!-- gh-comment-id:538485051 --> @SeyfSV commented on GitHub (Oct 4, 2019): For info: `http` module supports http2 requests. Issue occurs in `socket.io` module, that intercepts `Upgrade: h2c` header and brokes connection. As workaround I create socket Object only with `transports: 'pooling'` option. Yes, it disables WebSocket, but it is not critical for me.
Author
Owner

@SeyfSV commented on GitHub (Oct 4, 2019):

Hi, @htpcforall. I am not ready for showing my add-on :)
I wrote this simple class for interact with peerflix-server.
Also you can look on my fork of peerflix-server (branch pooling)

<!-- gh-comment-id:538488293 --> @SeyfSV commented on GitHub (Oct 4, 2019): Hi, @htpcforall. I am not ready for showing my add-on :) I wrote [this](https://gist.github.com/SeyfSV/175a45a5f6a677483a780c558f0393a8) simple class for interact with peerflix-server. Also you can look on my fork of peerflix-server (branch pooling)
Author
Owner

@SeyfSV commented on GitHub (Oct 2, 2021):

Now HTTP2 can be disabled in Kodi:

<disablehttp2>true</disablehttp2>

https://kodi.wiki/view/Advancedsettings.xml

<!-- gh-comment-id:932819003 --> @SeyfSV commented on GitHub (Oct 2, 2021): Now HTTP2 can be disabled in Kodi: ``` <disablehttp2>true</disablehttp2> ``` https://kodi.wiki/view/Advancedsettings.xml
Author
Owner

@timurlane commented on GitHub (Feb 8, 2022):

Hi @SeyfSV I was looking into developing a kodi plugin of my own (for Matrix). Did you end up succeeding with your project? I would really like to learn how to implement this.

<!-- gh-comment-id:1032566197 --> @timurlane commented on GitHub (Feb 8, 2022): Hi @SeyfSV I was looking into developing a kodi plugin of my own (for Matrix). Did you end up succeeding with your project? I would really like to learn how to implement this.
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/peerflix-server#354
No description provided.