{"action":"created","issue":{"url":"https://api.github.com/repos/feross/webtorrent/issues/283","labels_url":"https://api.github.com/repos/feross/webtorrent/issues/283/labels{/name}","comments_url":"https://api.github.com/repos/feross/webtorrent/issues/283/comments","events_url":"https://api.github.com/repos/feross/webtorrent/issues/283/events","html_url":"https://github.com/feross/webtorrent/issues/283","id":62772659,"number":283,"title":"STUN or TURN servers","user":{"login":"charlsagente","id":948024,"avatar_url":"https://avatars.githubusercontent.com/u/948024?v=3","gravatar_id":"","url":"https://api.github.com/users/charlsagente","html_url":"https://github.com/charlsagente","followers_url":"https://api.github.com/users/charlsagente/followers","following_url":"https://api.github.com/users/charlsagente/following{/other_user}","gists_url":"https://api.github.com/users/charlsagente/gists{/gist_id}","starred_url":"https://api.github.com/users/charlsagente/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charlsagente/subscriptions","organizations_url":"https://api.github.com/users/charlsagente/orgs","repos_url":"https://api.github.com/users/charlsagente/repos","events_url":"https://api.github.com/users/charlsagente/events{/privacy}","received_events_url":"https://api.github.com/users/charlsagente/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-18T18:55:53Z","updated_at":"2015-03-18T21:09:09Z","closed_at":"2015-03-18T21:09:09Z","body":"Is there a certain list of STUN or TURN servers do you use in your implementation? im using wireshark and i can see in some cases there is a TURN connections to some ips addresses for https://instant.io/. Are these servers for free? are yours? is possible to have my own list of servers and tell the webtorrent API to connect to it? \r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/9722348-stun-or-turn-servers?utm_campaign=plugin&utm_content=tracker%2F298985&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F298985&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/feross/webtorrent/issues/comments/83177575","html_url":"https://github.com/feross/webtorrent/issues/283#issuecomment-83177575","issue_url":"https://api.github.com/repos/feross/webtorrent/issues/283","id":83177575,"user":{"login":"feross","id":121766,"avatar_url":"https://avatars.githubusercontent.com/u/121766?v=3","gravatar_id":"","url":"https://api.github.com/users/feross","html_url":"https://github.com/feross","followers_url":"https://api.github.com/users/feross/followers","following_url":"https://api.github.com/users/feross/following{/other_user}","gists_url":"https://api.github.com/users/feross/gists{/gist_id}","starred_url":"https://api.github.com/users/feross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/feross/subscriptions","organizations_url":"https://api.github.com/users/feross/orgs","repos_url":"https://api.github.com/users/feross/repos","events_url":"https://api.github.com/users/feross/events{/privacy}","received_events_url":"https://api.github.com/users/feross/received_events","type":"User","site_admin":false},"created_at":"2015-03-18T21:09:09Z","updated_at":"2015-03-18T21:09:09Z","body":"In the browser, WebTorrent uses [`simple-peer`](https://github.com/feross/simple-peer) to create webrtc connections. WebTorrent just uses the default ICE server settings which use the free Google STUN server and no TURN servers. You can see the code [here](https://github.com/feross/simple-peer/blob/master/index.js#L105).\r\n\r\nSo, by default, WebTorrent won't use TURN (relay servers) since they can be expensive and aren't freely run by anyone. STUN, on the other hand, is required to establish webrtc connections.\r\n\r\nYou can specify your own STUN/TURN servers like this:\r\n\r\n```js\r\nvar rtcConfig = {\r\n  iceServers: [\r\n    {\"url\":\"stun:xx.xx.xx.xx\"},\r\n    {\"url\":\"turn:xx.xx.xx.xx\",\"username\":\"beep\",\"credential\":\"boop\"}\r\n  ]\r\n}\r\nnew WebTorrent({ rtcConfig: rtcConfig })\r\n```\r\n\r\nAnd, indeed, this is what https://instant.io is doing, since it uses a TURN relay server to increase reliability. This makes sense for a use-case like 1-to-1 or few-to-few file sharing, where any two peers MUST be able to connect. But for the general WebTorrent case, it doesn't make sense to use TURN since if you can't connect to some peers, it isn't the end of the world – you can always just connect to others."}}