Closed maxpavlov closed 5 years ago
Sorry, I'm not updated about Safari, I don't even have access to it. But there are some people here that uses PeerJS with Safari, let's wait them.
The error seems to come from the way Reliable is exported.
source -> import { Reliable } from "reliable";
babel -> var Reliable = require('reliable');
Changing the compiled code to the following works...
this._reliable = new Reliable.Reliable(this._dc, util.debug);
and then negotiator.js
is missing an import for Reliable
https://github.com/peers/peerjs/blob/master/lib/negotiator.ts#L226 & 280
[Error] Unhandled Promise Rejection: ReferenceError: Can't find variable: Reliable
EDIT: seems like a PR to fix it was opened but never merged https://github.com/michelle/reliable/pull/18/commits/a797057fe25174cee33f1eb7331b5808bd8a0ff5
An alternative for fixing this any not relying on this lib is to remove reliable: true
from your init config
Wow, I haven't access to that repo. @tombertrand what do you recommend? the fix to the import or just remove reliable: true
?
If it's better to have it, I'll clone the repo and do the update.
Tried tweeting and mailing to @michelle if she can merge this PR. Just hope she'll respond.
I've experimented with Safari, fixing JS errors caused by Reliable
lib and negotiator.ts
. There was no more errors but a message (ex: connection.send('hello');
) wouldn't reach the connections while on Chrome/FF there was no problem. I ended up doing reliable connections for the browsers that supports it, unreliable for unsupported browsers.
import Peer from 'peerjs';
import Util from 'peerjs/lib/util';
// Host
const peer = new Peer(HOST_PEER_ID, { secure: true, debug: 3 });
// Guests
const guestPeer = new Peer(null, { secure: true, debug: 3 });
const guestConnection = guestPeer.connect(HOST_PEER_ID, {
reliable: Util.supports.reliable, // true / false depending if the browser supports reliable connection
});
I've reached @michelle and she merged the PR in the reliable repo. Also a good workaround @tombertrand. But it's still sad to see reliable connections not working on Safari :(
It should just work then, because the package.json uses the latest master version from the repo.
Ok, so as 'reliable' part got fixed, I am still seeing this when I attempt to connect to peer from Safari 12:
Can anyone suggest what is wrong here? Thanks.
P.S. I noticed peerjs uses an outdated version of webrtc-adapter package. Maybe this is the reason why we often are getting out of sync integration wise. Just an assumption. P.P.S. I've forked peerjs, changed it to utilize the latest webrtc-adapter library and I still get the same error in Safari when trying to make a connection.
I was able to trace the problem down to this point. Once new t.RTCPeerConnection is called with an array of iceServers, it fails internally in the native code.
The problem turned out to be exactly as the error implies. I was passing in the array of url instead of urls and the array of actual strings containing the urls for stun servers. My mistake after all.
Is this related to #574 in any way? I tried using safari. If Safari is the host, it fail silently. If I try to connect another browser (ex, Chrome) to Safari, I get the error
Unhandled Promise Rejection: TypeError: Argument 1 ('options') to RTCPeerConnection.createOffer must be a dictionary
It seems to be a problem with i.createOffer(function(e) {
in peer.min.js
Whenever I am trying to connect to a peer in Safari with specifying an option of { reliable: true } I get an error:
TypeError: Object is not a constructor (evaluating 'new Reliable(this._dc, util.debug)')
Is there a way I can still use reliable data channel in Safari?