Closed SeyfSV closed 4 years ago
A PR is welcome.
Does Kodi require TLS? https://en.wikipedia.org/wiki/HTTP/2#Encryption
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.
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 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.
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.
@SeyfSV Fixed, I forgot to nest the options. I don't actually need this so I didn't test. :P
@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
Hmm... Maybe I spoke too soon. I'll let you know once I've had a chance to test this myself.
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 :smile:
@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!
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 toPlayer.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.
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.
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)
Now HTTP2 can be disabled in Kodi:
<disablehttp2>true</disablehttp2>
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.
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?