amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.14k stars 1.17k forks source link

WebRTC createDataChannel() doesn't work on Safari #834

Open huhsame opened 5 years ago

huhsame commented 5 years ago

I tested using lib/webrct.js It successfully works between Chrome and Chrome. But on Safari, WebRTC cannot createDataChannel.

1. Chrome - Chrome

it create data channel, and then it can send and recieve data even without server (websocket connection)

Screen Shot 2019-10-28 at 12 08 35 PM

2. Safari

First of all, I got an error about iceServers on Safari.

Member RTCIceServer.urls is required and must be an instance of (DOMString or sequence)

So I changed url to urls. After then, the error disappeared, but it still cannot connect with other peers. it creates WebRTC, and try to open. but that's all.

Screen Shot 2019-10-28 at 1 25 35 PM

Please take a look.

amark commented 5 years ago

@huhsame why does the Chrome one say websocket connection failed? Default GUN runs on 8765 I assume you've changed it to 3000?

Interesting that Safari has a different format, could you share the format that worked for you?

I have no clue Safari :/ I know it is often lagging behind, I'd need to find old minimum-viable-WebRTC-datachannel-only examples on the web and re-run/rest them, where have to copy&paste the signaling info, see if it works or if it still fails in Safari. There are a lot of "WebRTC" libraries that "work" but then you discovery they fallback to WebSockets or something else.

huhsame commented 5 years ago

@amark

The reason why WebSocket connection failed is that I shut down my server to test it without server, so that's not a problem and you might not need to mind it.

And I didn't use any different format from yours. the messages in the console are that I temporarily wrote in your webrtc.js code. I just made it print what event happens such as 'create', 'open', 'onDataChannel', 'onopen(= hi)', and 'onmessage'.

Anyway, I need to figure it out and make it work, so as you mentioned what you're gonna do, I'd also test other WebRTC libraries. I have no idea about WebRTC in detail X(

Safari : Version 13.0.2 (15608.2.30.1.1)

Thank you.

amark commented 5 years ago

@huhsame the error you got Member RTCIceServer.urls is required and must be an instance of (DOMString or sequence) ...

You see, in Chrome/Other browsers, this is how it is formatted: https://github.com/amark/gun/blob/master/lib/webrtc.js#L23-L29

Maybe Safari requires it as RTCIceServer.urls = ['url', 'url', 'url'] ? (I have no clue) but Safari shouldn't be complaining about the format if it is following same spec as Chrome/Firefox, etc.

I'm guessing your testing against iOS devices? And this is the need (since only Safari available on them), versus desktop?

hktalent commented 1 year ago

mee too cannot work on ios,but desktop system is ok

amark commented 1 year ago

noooooooooooooooo

does Safari just outright not support these RTC settings, or is it just some weird configuration bug? Can someone help figure out the magic Safari touch? (Apple and "web standards" hrrmmmmmmmm)

hktalent commented 1 year ago

@amark After research, it has been found that mobile devices require forwarding based on relay servers, and webrtc P2P cannot nat. Even if you see the IP: port of P2P, it is still not possible to successfully establish a P2P network Welcome to https://chat.51pwn.com:2083

hktalent commented 1 year ago

@amark desktop safari There's no problem, I can work well with webrtc here

noooooooooooooooo

does Safari just outright not support these RTC settings, or is it just some weird configuration bug? Can someone help figure out the magic Safari touch? (Apple and "web standards" hrrmmmmmmmm)

amark commented 1 year ago

@hktalent just iOS or both? So should we close, or what is the course of action?

hktalent commented 1 year ago

close, now I work ok on (iOS + macOS) + safari @amark you can see https://chat.51pwn.com:2083