gun icon indicating copy to clipboard operation
gun copied to clipboard

WebRTC createDataChannel() doesn't work on Safari

Open huhsame opened this issue 6 years ago • 9 comments

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.

huhsame avatar Oct 28 '19 04:10 huhsame

@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.

amark avatar Oct 28 '19 17:10 amark

@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.

huhsame avatar Oct 29 '19 01:10 huhsame

@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?

amark avatar Oct 31 '19 21:10 amark

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

hktalent avatar May 08 '23 12:05 hktalent

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 avatar May 11 '23 10:05 amark

@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 avatar May 11 '23 13:05 hktalent

@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)

hktalent avatar May 11 '23 13:05 hktalent

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

amark avatar May 21 '23 03:05 amark

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

hktalent avatar May 21 '23 06:05 hktalent