Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detail guide how to config file config.json #10

Open
quanghuy1288 opened this issue Aug 28, 2019 · 28 comments
Open

Detail guide how to config file config.json #10

quanghuy1288 opened this issue Aug 28, 2019 · 28 comments
Labels
documentation Documentation requests and issues

Comments

@quanghuy1288
Copy link

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

@mrlika
Copy link
Member

mrlika commented Aug 28, 2019

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 mrlika added the documentation Documentation requests and issues label Aug 28, 2019
@ckcr4lyf
Copy link

Mind if I ask what other features potentially?

@mrlika
Copy link
Member

mrlika commented Aug 28, 2019

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

@ckcr4lyf
Copy link

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.

@mrlika
Copy link
Member

mrlika commented Aug 28, 2019

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.

@ckcr4lyf
Copy link

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

@quanghuy1288
Copy link
Author

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 )

@ckcr4lyf
Copy link

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

@quanghuy1288
Copy link
Author

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

@ckcr4lyf
Copy link

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

@quanghuy1288
Copy link
Author

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

@mrlika
Copy link
Member

mrlika commented Aug 29, 2019

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.

@quanghuy1288
Copy link
Author

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?

@ckcr4lyf
Copy link

ckcr4lyf commented Aug 30, 2019

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

@quanghuy1288
Copy link
Author

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

@ckcr4lyf
Copy link

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

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

@quanghuy1288
Copy link
Author

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

@ckcr4lyf
Copy link

ckcr4lyf commented Aug 30, 2019

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.

@Alexdrr
Copy link

Alexdrr commented Aug 30, 2019

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

@quanghuy1288
Copy link
Author

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

@Alexdrr how to generate privkey.pem

@mrlika
Copy link
Member

mrlika commented Aug 30, 2019

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.

@ghost
Copy link

ghost commented Mar 3, 2020

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?

@mrlika
Copy link
Member

mrlika commented Mar 3, 2020

@ghost
Copy link

ghost commented Mar 4, 2020

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]'

@mrlika
Copy link
Member

mrlika commented Mar 4, 2020

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

@mrlika
Copy link
Member

mrlika commented Mar 4, 2020

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

@ghost
Copy link

ghost commented Mar 10, 2020

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

@mrlika
Copy link
Member

mrlika commented Mar 10, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation requests and issues
Projects
None yet
Development

No branches or pull requests

4 participants