Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
13.08k stars 1.51k forks source link

tracker, private: true = error 403 on wss://host/tracker/socket #6603

Closed ClusterM closed 1 month ago

ClusterM commented 1 month ago

Describe the current behavior

Tried versions 6.2.1 and 6.3.0 with the same result. Using tracker in private mode:

tracker:
  # If you disable the tracker, you disable the P2P on your PeerTube instance
  enabled: true
  # Only handle requests on your videos
  # If you set this to false it means you have a public tracker
  # Then, it is possible that clients overload your instance with external torrents
  private: true
  # Reject peers that do a lot of announces (could improve privacy of TCP/UDP peers)
  reject_too_many_announces: false

When I open and play any video, everything works fine the first time. However, after refreshing the page and clicking play again, I see the following error in the browser console: "WebSocket connection to 'wss://peertube.cluster.wtf/tracker/socket' failed."

I captured the traffic using Wireshark. Here's the request:

GET /tracker/socket HTTP/1.1
X-Forwarded-For: 109.75.37.219
Host: peertube.cluster.wtf
X-Real-IP: 109.75.37.219
Upgrade: websocket
Connection: upgrade
X-Forwarded-Proto: https
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Origin: https://peertube.cluster.wtf
Sec-WebSocket-Version: 13
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,es-ES;q=0.6,es;q=0.5,hy;q=0.4,sr;q=0.3
Cookie: _ym_uid=1702386692149719549; _ym_d=1721495874; _ga_KFGNEREP09=GS1.2.1723906768.16.0.1723906768.0.0.0; __utma=125388683.463117433.1701005819.1724323437.1724323437.1; __utmz=125388683.1724323437.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ga=GA1.1.463117433.1701005819; _ga_S2B025ZGBN=deleted; _ga_H5XS8EQPP2=GS1.1.1726149866.12.1.1726149887.0.0.0; clientLanguage=ru-RU; _ga_EQDN3BWDSD=GS1.1.1726507536.33.0.1726507536.0.0.0; _ga_S2B025ZGBN=GS1.1.1726915654.110.1.1726917591.0.0.0
Sec-WebSocket-Key: s3bdGH59sAB5abay99FDBw==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits

And the response:

HTTP/1.1 403 Forbidden

It seems like the PeerTube log doesn't contain any specific information about this issue when I request a video, but sometimes I see this error (109.75.37.219 is my local IP):

{
   "err":{
      "stack":"Error: Unknown infoHash 921d167a1ef158020d4a1622938fa17056690628 requested by ip 109.75.37.219\n    at Server.filter [as _filter] (file:///home/peertube/versions/peertube-v6.3.0/dist/core/controllers/tracker.js:50:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
      "message":"Unknown infoHash 921d167a1ef158020d4a1622938fa17056690628 requested by ip 109.75.37.219"
   },
   "level":"warn",
   "message":"Warning in tracker.",
   "label":"peertube.cluster.wtf:443",
   "timestamp":"2024-09-21T12:15:25.467Z"
}

My nginx configuration is nearly the same as the one provided in support/nginx/peertube.

As a result, the video plays, but every viewer only sees "1 peer." But everything works as expected if I set private to false.

Steps to reproduce

  1. Set enabled and private to true in the tracker section of config file.
  2. Try to play any video multiple times.
  3. Check console of your web browser and peer counter.

Describe the expected behavior

  1. No errors in the browser console
  2. P2P that actually works

Additional information

Chocobozzz commented 1 month ago

Hi,

Does your instance currently use private: false? Because I can't reproduce with one of your latest local video

ClusterM commented 1 month ago

Does your instance currently use private: false? Because I can't reproduce with one of your latest local video

It's private: true now. Try to refresh the page multiple times or play the video in multiple tabs.

Chocobozzz commented 1 month ago

Are you able to reproduce with https://peertube.cluster.wtf/w/kCv7MiMTqgsMLZm2qM6uwS?

ClusterM commented 1 month ago

Are you able to reproduce with https://peertube.cluster.wtf/w/kCv7MiMTqgsMLZm2qM6uwS?

Yes, after multiple page refreshes and playing video in multiple tabs. Try it right now.

ClusterM commented 1 month ago

It works now. Weird. Try this video: https://peertube.cluster.wtf/w/2WPxHKxccHgFvCWJW62Q7D

Chocobozzz commented 1 month ago

Thanks! Then I think it's the same issue as https://github.com/Chocobozzz/PeerTube/issues/6516 But it's weird you still have the issue with 6.2.1. How did you configure S3 on your instance?

ClusterM commented 1 month ago

I'm using my own Python script to upload files to the Google Cloud: https://pastebin.com/qrMH25Y6 But I 100% saw this error on local videos too. My friend uses PeerTube with local videos only (and embedded only): https://kinamania.com/video/na-kukhne/49-7-season-nakuhne/315-na-kuhne-76 Try to open this URL in multiple tabs. Same problem.

Chocobozzz commented 1 month ago

I'm using my own Python script to upload files to the Google Cloud: https://pastebin.com/qrMH25Y6

Please use https://docs.joinpeertube.org/maintain/tools#move-video-files-from-object-storage-to-filesystem instead, your method that update directly the database is not supported by PeerTube.

My friend uses PeerTube with local videos only

Can he provide more information on how he uploaded the videos/what is the PeerTube configuration? Can he try to update the video privacy from public -> private and then private -> public?