Code Monkey home page Code Monkey logo

wt-tracker's People

Contributors

antonshchemelev avatar dimademchenko avatar mrlika avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wt-tracker's Issues

Improve error messages

I have no good error messages from the underlying uWebSockets.js library about problems with SSL keys and other stuff. That is why just report "failed to start the web server: App construction failed"
I will try to improve the messages.

Originally posted by @mrlika in #10 (comment)

tracker return 404

hi sir, i try to build the tracker.. but i confuse, when i connect using wss or ws always return 404. i try to add index.html header return 404 no 101 switching

Publish on `npm`

Publish project on npm and add documentation about its API and how to use it as a dependency.

Tracker crash when a client refreshes frontend video page

Hey, first of all thanks for a great repository.

I noticed what I think is a bug, when I was testing the tracker. I was making use of a minimal frontend demo from p2p-media-loader, and wanted to try my own tracker.

When I use wt-tracker, I was testing on a remote server, with one instance on my PC and one on my mobile. PC is on Lan, and Mobile is on Wifi (different networks, but more on this later).

So initially when the tracker is first loaded, communication works great, I can see load being shared, and p2p requests / announces being sent. But if I reload the tab / website in either my PC or my phone, an exception is thrown which I have traced back to

throw e;

The error specifically is (in the tracker console):

Invalid access of closed uWS.WebSocket/SSLWebSocket.

And p2p communication stops. When I reloaded on my phone, (so I could check PC chrome console), I saw an Ice Connection error as well (might be related to old peer data which doesn't exist? And since tracker crashed cannot get new peer, so unloaded PC tries to communicate with old peer)

2p-media-loader-core.min.js:1 p2pml:media-peer peer error +888ms 06ddf104bb2ff52210bc9c0394b7f48f912a420d Error: Ice connection failed.
    at l (p2p-media-loader-core.min.js:1)
    at c._onIceStateChange (p2p-media-loader-core.min.js:1)
    at RTCPeerConnection.r._pc.oniceconnectionstatechange (p2p-media-loader-core.min.js:1) n.MediaPeer {_events: {…}, _eventsCount: 10, _maxListeners: undefined, peer: c, settings: {…}, …}
p2p-media-loader-core.min.js:1 p2pml:media-peer peer close +1ms 06ddf104bb2ff52210bc9c0394b7f48f912a420d n.MediaPeer {_events: {…}, _eventsCount: 10, _maxListeners: undefined, peer: c, settings: {…}, …}

and then rightly discards the non-responsive peer.

I have tried the same refresh scenario with bitorrent-tracker, and have not observed a crash, so I think it is specific to this library, rather than wss based trackers.

Further, a simple restart of the tracker and waiting around ~30 secs the two devices connect again and communication begins.

So, theoretically I guess using pm2 it is possible to restart on this crash, but if it could be avoided then its probably better.

Lastly, I've been reading the code since I am extremely interested in P2P and had initially thought of making something on my own before I discovered your amazing work. However, I'm having some trouble reading it initially, since the work I've done in node.js is mostly server-side, and I'm unfamiliar with .ts and some files just containing what seem like definitions. If you could point me in the right direction I'd greatly appreciate it, and hopefully I can contribute a lot of features to the repository!

Thanks

P.S. on my two devices I have two separate public IPs, but in the console I can see the IP that it gets of my phone as a private one (both are connected to different networks but by my University), was wondering how this works? Not asking for a detailed explanation, but just a few keywords I can search and read up on.

Can't run on RaspberryPi: Error Cannot find module './uws_linux_arm_88.node'

When I try to run wt-tracker with node dist/run-uws-tracker.js config.json I get:
`/home/pi/wt-tracker/node_modules/uWebSockets.js/uws.js:31
throw new Error('This version of µWS is not compatible with your Node.js build:\n\n' + e.toString());
^

Error: This version of µWS is not compatible with your Node.js build:

Error: Cannot find module './uws_linux_arm_88.node'
Require stack:

  • /home/pi/wt-tracker/node_modules/uWebSockets.js/uws.js
  • /home/pi/wt-tracker/dist/uws-tracker.js
  • /home/pi/wt-tracker/dist/run-uws-tracker.js
    at /home/pi/wt-tracker/node_modules/uWebSockets.js/uws.js:31:9
    at Object. (/home/pi/wt-tracker/node_modules/uWebSockets.js/uws.js:33:3)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object. (/home/pi/wt-tracker/dist/uws-tracker.js:33:26)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)`

NodeJs v15.8.0
NPM v7.5.3

Dockerize

I've been trying without success. Have anyone been able to run this dockerized?

Peer only with users coming from the same IP

I work for a rural educational network of a few elementary schools. The schools have varying internet connectivity. All the computers on each network run behind NAT and have a single IP exposed to the internet. I'd like to see if it's possible to only announce peers that come from the same IP address so that peering would be confined within each schools local network,

Error: This version of µWS is not compatible with your Node.js buil

I got this error:
`/root/wt-tracker/node_modules/uWebSockets.js/uws.js:31
throw new Error('This version of µWS is not compatible with your Node.js build:\n\n' + e.toString());
^

Error: This version of µWS is not compatible with your Node.js build:

Error: /lib64/libc.so.6: version GLIBC_2.18' not found (required by /root/wt-tracker/node_modules/uWebSockets.js/uws_linux_x64_64.node) at module.exports (/root/wt-tracker/node_modules/uWebSockets.js/uws.js:31:9) at Object.<anonymous> (/root/wt-tracker/node_modules/uWebSockets.js/uws.js:33:3) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (/root/wt-tracker/dist/uws-tracker.js:18:26)

How to install WT-Tracker ? (Windows)

Hello,

Sorry, this is probably a stupid question, but I have issues installing WT-Tracker on my machine..

  1. I download the repository as zip.
  2. I unpack the zip file, and open a cmd in the root folder.
  3. I run npm install.

And while installing, I got a HUGE list like this of missing files..
image

Have I done something wrong ?

Thanks !

How to save logs of wt

How to config logs for wt ?
i need save some information, example ip address of client, domain, error logs, access logs ... ?

Cluster solution

I want to scale mutil wt-tracker machine as a cluster, how can i do ?

Running behind nginx on subdirectory possible?

I am trying to setup wt-tracker to run behind nginx on https://example.com/wt but I am not able to curl https://example.com/wt/stats.json even though I can connect with wscat.

my config.json:

{
  "servers": [{
      "server": {
        "port": 19823,
        "host": "127.0.0.1"
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1,
        "maxConnections": 100
      }
    }
  ],

  "tracker": {
    "maxOffers": 20,
    "announceInterval": 120
  },

  "websocketsAccess": {
    "allowOrigins": ["https://example.com"],
    "denyEmptyOrigin": true
  }
}

nginx entry:

location /wt {
            proxy_pass http://127.0.0.1:19823/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host;
}

Do I need to change "path": "/*", to something else? "/wt/*" did not work for me as I got error 404 with wscat.
Is it even possible that such a setup succeeds?
I am trying to curl stats.json because I want to know that wt-tracker works correctly.

wt-tracker with uWebSockets.js v#20.15.0 error

/home/wt-tracker/dist/uws-tracker.js:67
const origin = request.getHeader("origin");
^

TypeError: Cannot read properties of undefined (reading 'getHeader')
at UWebSocketsTracker.onOpen (/home/wt-tracker/dist/uws-tracker.js:67:40)

How to Fix it ? i try change onOpen to onUpdate but allow origin not working.

Is it possible to not show 'peersCountPerInfoHash' ?

Hello,

After I update to the latest version I found that stats.json has addition info peersCountPerInfoHash when connection is hight it's seem to slow down stats.json. Is it possible to disable it for showing ?

Regards,
Steven

Add option to serve `public` folder

At

).any(
"/*",
(response: HttpResponse, request: HttpRequest) => {
debugRequest(server, request);
const status = "404 Not Found";
response.writeStatus(status).end(status);
},
);
is being explicitly forbidden to serve any content that are not the WebTorrent WebSocket connections, the JSON stats endpoint, or an index.html file. In the same way that serving the index.html file is an opt-in, it would be useful to allow to check and serve a public folder before give up and return a 404, maybe being the index.html file inside it. That would allow to serve not only some Javascript and CSS files associated with the index.html file, but more important, it would allow to serve the actual HLS fragments directly from the same server, without needing to spin-up other processes.

wss:// (HTTPS) not working (including on p2p-media-loader's own demo page)

Hello,
I've noticed that on p2p-media-loader's demo page I am unable to connect to wss://tracker.novage.com.ua :

WebSocket connection to 'wss://tracker.novage.com.ua/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Today I am running wt-tracker for testing purposes on a VPS and I am experiencing the same issue on my server. HTTP appears to work properly without issues, but HTTPS comes up with the same error, while uws-tracker-requests debug does not show any connection attempts for HTTPS. Wt-tracker starts normally without errors, and port 443 comes up correctly when checked:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      3895/node           
tcp        0      0 0.0.0.0:433             0.0.0.0:*               LISTEN      3895/node  

Testing with other trackers like wss://tracker.openwebtorrent.com does work . I did not see such an issue opened or closed so could it be somehow on my end? Can anyone confirm they have the same issue?

EDIT
Tested on Mac and Windows 10, with Chrome and Firefox latest. Results are the same.

Thank you

peer.ip ?

Hello
how can i get ip of peer in FastTracker.processMessage(json, peer) ?

Upstream your performance improvements?

Hi there,

Maintainer of bittorrent-tracker here. Just wondering if you had any interest in upstreaming your improvements back into the main bittorrent-tracker package so that more users could benefit from your work here.

Thanks!

Unexpected response code: 200

Hi!

I'm having a error response.
(Error during WebSocket handshake: Unexpected response code: 200)

my config.json:

{
"servers": [{
"server": {
"port": 8000,
"host": "0.0.0.0"
},
"websockets": {
"path": "/*",
"maxPayloadLength": 65536,
"idleTimeout": 240,
"compression": 1,
"maxConnections": 0
}
}
],

"tracker": {
"maxOffers": 20,
"announceInterval": 120
},

"websocketsAccess": {
"denyEmptyOrigin": true
}
}

in p2p-media-loader-core.js:

trackerAnnounce: ["ws://35.193.240.193", "wss://tracker.openwebtorrent.com"],

when i set ws://35.193.240.193:8000 in trackerAnnounce, i get the error:

failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

P.s:
I moved the config.json file from the "sample" folder to the root and run this (npm start config.json)

Can't install on Centos 7.7

Error: This version of µWS is not compatible with your Node.js build:
Error: /lib64/libc.so.6: version `GLIBC_2.18' not found
How to fix ? i had tried but can't install glibc-2.18 on Centos 7.7

Installing from Scratch on Centos 7

There wasn't a clear guide of how to install and run this tracker from scratch. I thought it would be helpful for others.

Installing Nodejs

sudo yum install epel-release
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
sudo yum install nodejs
node -v

v12.17.0

Installing Git and cloning Repository

yum install git
cd /usr/local
git clone https://github.com/Novage/wt-tracker.git

Installing wt-tracker

cd wt-tracker/
npm install
npm run build

#uWebSockets version v15.11.0 needed, so we are reinstalling uWebSockets
npm uninstall uWebSockets.js
npm install uNetworking/uWebSockets.js#v15.11.0

Creating config.json

vi /usr/local/wt-tracker/config.json

{
  "servers": [{
      "server": {
        "port": 80,
        "host": "0.0.0.0"
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1,
        "maxConnections": 0
      }
    }, {
      "server": {
        "port": 443,
        "host": "0.0.0.0",
        "key_file_name": "/etc/ssl/certs/key.pem",
        "cert_file_name": "/etc/ssl/certs/crt.pem",
        "ssl_prefer_low_memory_usage": true
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }
  ],

  "tracker": {
    "maxOffers": 20,
    "announceInterval": 120
  },

  "websocketsAccess": {
    "allowOrigins": ["https://website.com"],
    "denyEmptyOrigin": true
  }
}

Adding firewall rules

firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/tcp
firewall-cmd --reload
firewall-cmd --zone=public --list-all

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: dhcpv6-client ssh
  ports: 80/tcp 443/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules:

Creating Service

vi /etc/systemd/system/wt-tracker.service

Description=WebTorrent Tracker

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
WorkingDirectory=/usr/local/wt-tracker
ExecStart=/usr/local/wt-tracker/bin/wt-tracker

[Install]
WantedBy=multi-user.target

Activating and Enabling Service

systemctl enable wt-tracker
systemctl restart wt-tracker
systemctl status wt-tracker

● wt-tracker.service - WebTorrent Tracker
   Loaded: loaded (/etc/systemd/system/wt-tracker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-05-30 12:29:55 CEST; 30min ago
 Main PID: 896 (node)
   CGroup: /system.slice/wt-tracker.service
           └─896 node /usr/local/wt-tracker/bin/wt-tracker

May 30 12:29:55 localhost systemd[1]: Started WebTorrent Tracker.
May 30 12:29:55 localhost wt-tracker[896]: listening 0.0.0.0:80
May 30 12:29:55 localhost wt-tracker[896]: listening 0.0.0.0:443

Increasing Open File Limit for Service

#This changes will fix Error: EMFILE: too many open files, uv_resident_set_memory

mkdir /etc/systemd/system/wt-tracker.service.d/
vi /etc/systemd/system/wt-tracker.service.d/limits.conf

[Service]
LimitNOFILE=65535

systemctl daemon-reload
systemctl restart wt-tracker.service

Checking Stats

https://127.0.0.1/stats.json

{
  "torrentsCount": 0,
  "peersCount": 0,
  "servers": [
    {
      "server": "0.0.0.0:80",
      "webSocketsCount": 0
    },
    {
      "server": "0.0.0.0:443",
      "webSocketsCount": 0
    }
  ],
  "memory": {
  }
}

Replay Error

when video finish and replay button appear, when we click replay it got error and no replay video. any solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.