RangerMauve / hyperswarm-web

Implementation of the hyperswarm API for use in web browsers
MIT License
102 stars 15 forks source link

ICE failed, add a TURN server #1

Closed pasqui23 closed 4 years ago

pasqui23 commented 4 years ago

As seen in https://github.com/pasqui23/.hswm-bug After doing

node bin/hyperswarm.js & yarn run dev

And open 2 broswer tabs at http://localhost:1234 After sending a username,If I then send a message I get in the js console

ICE failed, add a TURN server and see about:webrtc for more details

Even through a ws proxy on localhost should run (thanks to node bin/hyperswarm.js)

RangerMauve commented 4 years ago

Hey, I don't think there's much I can do about WebRTC requiring a TURN server for your case. It might be a firewall issue, though. 😅

Is the page successfully connecting to your local ws proxy? I think at the moment ws proxies don't connect browsers together since it assumes they can connect over WebRTC.

Would adding config options for presenting a TURN server help your use case?

pasqui23 commented 4 years ago

Yes,an option for a TURN server would be good.It would be good also an option to use both wrtc and websocket proxy toghether.

What do you mean firewall issue?

pasqui23 commented 4 years ago

Update:even after adding

simplePeer: {
        iceServers:require("./turn.jsonc")
      }

To the options passed to the hyperswarm-web constructor,the problem still remain intact

turn.jsonc is taken from https://gist.github.com/yetithefoot/7592580

pasqui23 commented 4 years ago

This under the assumption that simplePeer is an object that get passed to the constructor of simple-peer which then passes it to RTCPeerConnection

RangerMauve commented 4 years ago

@tinchoz49 Should passing simplePeer in that format to discovery-swarm-webrtc work?

tinchoz49 commented 4 years ago

Hey everyone!

Doing:

simplePeer: {
        iceServers:require("./turn.jsonc")
      }

wont work, simplePeer is an object of options for the simplePeer instance so you need to follow the spec options here: https://github.com/feross/simple-peer#peer--new-peeropts

that means:

simplePeer: {
   config: { iceServers: [{ urls: 'stun:stun.l.google.com:19302' }, { urls: 'stun:global.stun.twilio.com:3478?transport=udp' }] }
}

Remember to pass an Array of objects.

RangerMauve commented 4 years ago

Awesome, thank you for clarifying Martin! 💜

@pasqui23 Would you be down for sending a PR to add some documentation on setting up STUN and TURN servers in the README once you've got it working? 😁

pasqui23 commented 4 years ago

@RangerMauve done https://github.com/RangerMauve/hyperswarm-web/pull/2