wt-tracker icon indicating copy to clipboard operation
wt-tracker copied to clipboard

Detail guide how to config file config.json

Open quanghuy1288 opened this issue 6 years ago • 28 comments

Detail guide how to config file config.json. I can not config it

quanghuy1288 avatar Aug 28 '19 09:08 quanghuy1288

We will do it but currently working on other P2P functionality.

Everything is very simple. Check the example: https://github.com/Novage/wt-tracker/blob/master/sample/config.json

Most of the stuff is self-explanatory.

mrlika avatar Aug 28 '19 12:08 mrlika

Mind if I ask what other features potentially?

ckcr4lyf avatar Aug 28 '19 12:08 ckcr4lyf

Working on:

  • C++ implementation of the tracker that will allow using memory more efficiently comparing to Node.js. On a low-cost VPS that usually goes with 1 vCPU and 1-2GiB of RAM the bottleneck is the RAM.
  • Improving and testing this Node.js version of the tracker - looks like memory consumption is better when running on recently released Node.js v12.9.1
  • P2P Media Loader issues and improvements

mrlika avatar Aug 28 '19 13:08 mrlika

C++ implementation sounds great, best of luck

I have a suggestion / request for P2P media loader, functionality for having a stream completely powered by P2P, somewhat like Acestream?

One "server" has a source, which it to "clients" only via P2P, i.e. a WebRTC based connection to the server, for both the manifest as well as fragments.

A partial way to do it is change the HTTP fragment probability to 0, but it still relies on the HTTP for the manifest (.m3u8)

I am trying to understand the library to see if I can do it myself, but seems a bit tricky.

ckcr4lyf avatar Aug 28 '19 13:08 ckcr4lyf

As far as I know, Ace Stream is not completely powered by P2P. In Ace Stream you have to stream video to their server. Initial video data is loaded from their server. You can see it when streaming stops - they loop the same few seconds of video each time you try to play the stream.

P2P Media Loader has no vendor lock. You can stream through any server\CDN.

I don't know production-ready completely serverless live P2P video streaming solutions. Bittorrent is working on it many years already.

mrlika avatar Aug 28 '19 13:08 mrlika

Yeah, that is true. Ace stream "contentIDs" need to be validated on their server with their black-box code.

Thanks for the feedback, I shall continue to explore this field. Cheers

ckcr4lyf avatar Aug 28 '19 14:08 ckcr4lyf

I have clone your project to my centos 7 server (you can check via my httpd http://103.216.120.135:85/p2p/wt-tracker/). Then i install nodejs 12 then run 2 commands:

npm install
npm run build

Then i try to start wt-tracker: ./bin/wt-tracker _config.json (check detail from _config.json; and check pem file which i have used in _config.json in this http://103.216.120.135:85/p2p/keyssl/ ) but it show

listening 0.0.0.0:8000
failed to start the web server: App construction failed

If i run wt-tracker without param: ./bin/wt-tracker it not show error but my demo p2p-media-loader cannot connect this wt-tracker. p2p-media-loader-core.min.js:1 WebSocket connection to 'wss://103.216.120.135:8000/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED

(you can check my demo p2p-media-loader from this link http://103.216.120.135:85/p2p/custom.html )

quanghuy1288 avatar Aug 29 '19 03:08 quanghuy1288

Try forcing a ws:// connection instead of wss:// (in your HTML page) and see if that works

ckcr4lyf avatar Aug 29 '19 04:08 ckcr4lyf

Try forcing a ws:// connection instead of wss:// (in your HTML page) and see if that works

Thanks!. It work when i run wt-tracker without config.json

But with config.json wt-tracker still failed to start

quanghuy1288 avatar Aug 29 '19 06:08 quanghuy1288

Try removing the SSL configuration in your _config.json file, specifically this part:

, {
      "server": {
        "port": 8433,
        "host": "0.0.0.0",
        "key_file_name": "/home/vega/p2p/keyssl/server.key.pem",
        "cert_file_name": "/home/vega/p2p/keyssl/server.cert.pem",
        "passphrase": "[redacted]",
        "ssl_prefer_low_memory_usage": true
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }

I'll try and spin up a VPS with wt-tracker and see if I can get it to work with a config.json

ckcr4lyf avatar Aug 29 '19 06:08 ckcr4lyf

Try removing the SSL configuration in your _config.json file, specifically this part:

, {
      "server": {
        "port": 8433,
        "host": "0.0.0.0",
        "key_file_name": "/home/vega/p2p/keyssl/server.key.pem",
        "cert_file_name": "/home/vega/p2p/keyssl/server.cert.pem",
        "passphrase": "[redacted]",
        "ssl_prefer_low_memory_usage": true
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }

I'll try and spin up a VPS with wt-tracker and see if I can get it to work with a config.json

Ok thanks, it worked when i do as your guide

quanghuy1288 avatar Aug 29 '19 07:08 quanghuy1288

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.

mrlika avatar Aug 29 '19 09:08 mrlika

I have tried to config ssl. then using it in my demo http://103.216.120.135:85/p2p/custom.html But error show from console : WebSocket connection to 'wss://103.216.120.135:8433/' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID

Could you guide me to fix this problem?

quanghuy1288 avatar Aug 30 '19 08:08 quanghuy1288

That means your SSL certificate is not validated by global CA authorities. Did you just create a pair with OpenSSL?

Browsers do not allow secure connections to certificates that have not been verified by a root CA.

If you need a free SSL certificate for your domain you can check out Lets Encrypt E..g for github: image

ckcr4lyf avatar Aug 30 '19 08:08 ckcr4lyf

Could you guide me create ssl cert with Lets Encrypt. I have been configured nginx with certbot and Lets Encrypt. It work well.

But with wt-tracker i do not know how to config. Could you help me

quanghuy1288 avatar Aug 30 '19 09:08 quanghuy1288

By default, the certificates are placed in /etc/letsencrypt/live/YOUR-DOMAIN/

You can try pointing here as the path in your config.json

ckcr4lyf avatar Aug 30 '19 09:08 ckcr4lyf

I do as your guide and new error issue: p2p-media-loader-core.min.js:1 WebSocket connection to 'wss://103.216.120.135:8433/' failed: Error in connection establishment: net::ERR_CERT_COMMON_NAME_INVALID

quanghuy1288 avatar Aug 30 '19 09:08 quanghuy1288

You certificate is signed to your domain. So, when you connect using a secure connection, you must specify your domain, such as wss://streming.tk:8433/, and not just the IP.

ckcr4lyf avatar Aug 30 '19 09:08 ckcr4lyf

I used a bunch of cloudflare flexible ssl for the domain of the tracker. For the tracker itself, I used a self-signed server certificate. everything works fine. My config.json

{
  "servers": [{
      "server": {
        "port": 8000,
        "host": "0.0.0.0"
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }, {
      "server": {
        "port": 8433,
        "host": "0.0.0.0",
        "key_file_name": "/home/user/wt/misc/key.pem",
        "cert_file_name": "/home/user/wt/misc/cert.pem",
        "passphrase": "1234",
        "dh_params_file_name": "/home/user/wt/misc/dh.dh",
        "ssl_prefer_low_memory_usage": true
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }
  ],

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

  "websocketsAccess": {
    "allowOrigins": ["http://domain.life"],
    
    "denyEmptyOrigin": true
  }
}

To create a self-signed server certificate you need to run the command (linux)

user@server:~$ openssl req -new > cert.csr
user@server:~$ openssl rsa -in privkey.pem -out key.pem
user@server:~$ openssl x509 -in cert.csr -out cert.pem -req -signkey key.pem -days 1001
user@server:~$ cat key.pem>>cert.pem 
user@server:~$ openssl dhparam -out /home/user/wt/misc/dh.dh 2048

Alexdrr avatar Aug 30 '19 10:08 Alexdrr

openssl rsa -in privkey.pem -out key.pem

@Alexdrr how to generate privkey.pem

quanghuy1288 avatar Aug 30 '19 10:08 quanghuy1288

My config for wss://tracker.novage.com.ua

{
  "servers": [{
    "server": {
      "port": 443,
      "host": "0.0.0.0",
      "key_file_name": "/etc/letsencrypt/live/tracker.novage.com.ua/privkey.pem",
      "cert_file_name": "/etc/letsencrypt/live/tracker.novage.com.ua/fullchain.pem",
      "ssl_prefer_low_memory_usage": true
    },
    "websockets": {
      "path": "/*",
      "maxPayloadLength": 16384,
      "idleTimeout": 240,
      "compression": 1
    }
  }, {
    "server": {
      "port": 80,
      "host": "0.0.0.0"
    },
    "websockets": {
      "path": "/*",
      "maxPayloadLength": 16384,
      "idleTimeout": 240,
      "compression": 1
    }
  }],

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

How to use letsencrypt to get free certificates for your domain on your server you should read the guides. Google it. Many articles, many approaches.

mrlika avatar Aug 30 '19 10:08 mrlika

My config for wss://tracker.novage.com.ua

{
  "servers": [{
    "server": {
      "port": 443,
      "host": "0.0.0.0",
      "key_file_name": "/etc/letsencrypt/live/tracker.novage.com.ua/privkey.pem",
      "cert_file_name": "/etc/letsencrypt/live/tracker.novage.com.ua/fullchain.pem",
      "ssl_prefer_low_memory_usage": true
    },
    "websockets": {
      "path": "/*",
      "maxPayloadLength": 16384,
      "idleTimeout": 240,
      "compression": 1
    }
  }, {
    "server": {
      "port": 80,
      "host": "0.0.0.0"
    },
    "websockets": {
      "path": "/*",
      "maxPayloadLength": 16384,
      "idleTimeout": 240,
      "compression": 1
    }
  }],

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

How to use letsencrypt to get free certificates for your domain on your server you should read the guides. Google it. Many articles, many approaches.

Where should I put this config.json?

ghost avatar Mar 03 '20 15:03 ghost

https://github.com/Novage/wt-tracker#run-instructions

mrlika avatar Mar 03 '20 23:03 mrlika

https://github.com/Novage/wt-tracker#run-instructions

When I run ./bin/wt-tracker [config.json] It show error: failed to read configuration file: Error: ENOENT: no such file or directory, open '[config.json]'

ghost avatar Mar 04 '20 07:03 ghost

You should run as ./bin/wt-tracker config.json

mrlika avatar Mar 04 '20 10:03 mrlika

[ ] usually means optional parameter when a CLI tool is described

mrlika avatar Mar 04 '20 10:03 mrlika

You should run as ./bin/wt-tracker config.json

Screen Shot 2020-03-10 at 1 13 02 PM Still not working as the screen shoot

ghost avatar Mar 10 '20 06:03 ghost

It says that config.json file is missing in the working/current directory

mrlika avatar Mar 10 '20 20:03 mrlika