Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with safari and chrome ios 13 #599

Open
riccardogermana opened this issue Nov 27, 2019 · 17 comments
Open

Not working with safari and chrome ios 13 #599

riccardogermana opened this issue Nov 27, 2019 · 17 comments
Labels
confirmed acknowledged as an issue documentation need update some info in doc platform-specific issues affecting only specific platforms

Comments

@riccardogermana
Copy link

riccardogermana commented Nov 27, 2019

274607b8-5a0f-4e15-9b81-5483d3375eaf

I got this problem over chrome and safari, both desktop and mobile, initially it start the IceConnection, but after it got queued, it just stays in that state, and do not connect in anyway. I tried to read into some of the issues of the Git, but even with the change of the code (added URLS, used configs from PeerJs) on connection with Safari still have the problem. Somebody have any advice that can help me with this problem?

const peer = new Peer(id, {
      host: '192.168.202.65',
      port: 9000,
      path: '/peerjs',
      debug: 3,
      config: {
        iceServers: [
          {urls: 'stun:stun.l.google.com:19302'},
          {urls: 'turn:0.peerjs.com:3478', username: 'peerjs', credential: 'peerjsp'}
        ]
      }
    });
    peer.on('open', () => {
      peer.connect(this.anotherid, {
        reliable: true
      });
    });
    peer.on('connection', (conn) => {
      console.log('connection');
      conn.on('open', () => {
        conn.send(new DataConnection('coordinate', {lat: this.lat, long: this.long}));
        console.log('connected');
      });
      conn.on('error', (err) => {
        Swal.fire({
          icon: 'error',
          title: 'ERRORE',
          text: err
        });
      });
      conn.on('close', (err) => {
        console.log(err);
      });
      conn.on('data', (data) => {
        this.action(data);
        console.log(data);
      });
      this.conn = conn;
    });

@maxpavlov
Copy link

Its broken for Safari and has been broken for iOS Safari and Chrome for quite a while. DataChannel there doesn't support binaryBlob sending, while the util for these systems report it is supported. You have to introduce a custom fix. I did it and it works. For me, with current 1.1.0 version, desktop safari is also affected.

@riccardogermana
Copy link
Author

What type of custom fix?

@Niksac
Copy link

Niksac commented Nov 29, 2019

This might be the problem for my #598 too.
I am also interested in the fix @maxpavlov

@Niksac
Copy link

Niksac commented Nov 30, 2019

@riccag3
Thanks to the hint of maxpavlov, I fixxed it too in my project:

When connecting, the connection options, set serialization to 'json' (preferably only on Safari devices).

Here is some sample code on how I did it:

function checkSafari() {
  let seemsChrome = navigator.userAgent.indexOf("Chrome") > -1;
  let seemsSafari = navigator.userAgent.indexOf("Safari") > -1;
  return seemsSafari && !seemsChrome;
}

let peerOptions = {};

if (checkSafari()) {
  peerOptions.serialization = "json";
}

conn = peer.connect('ABCDEFG', peerOptions);

@maxpavlov
Copy link

maxpavlov commented Dec 2, 2019

@Niksac just when I came here to actually provide a fix code =) Thanks. As I know @afrokick is aware of the problem, and has even updated the docs to reflect the "only json" nature of Safari. However, I think, that we not only should inform the developers that they should use serialization = "json" for peerOptions to support Safari, we should allow binary format but for safari, fall back to a working approach in dataconnection.ts of the peerjs library.

@riccardogermana
Copy link
Author

I tried to add this line but don't work, it does the same thing as before

initConn(id) {
    const peerConf: any = {
      host: '192.168.202.65',
      port: 9000,
      path: '/peerjs',
      debug: 3,
      config: {
        iceServers: [
          {urls: 'stun:stun.l.google.com:19302'},
          {urls: 'turn:0.peerjs.com:3478', username: 'peerjs', credential: 'peerjsp'}
        ]
      },
    };
    const peerOptions: any = {};
    if (this.checkSafari()) {
      peerOptions.serialization = 'json';
    }
    const peer = new Peer(id, peerConf);
    peer.on('open', () => {
      peer.connect(this.anotherid, peerOptions);
    });
    peer.on('connection', (conn) => {
      conn.on('open', () => {
        conn.send(new DataConnection('coordinate', {lat: this.lat, long: this.long}));
        console.log('connected');
      });
      conn.on('error', (err) => {
        Swal.fire({
          icon: 'error',
          title: 'ERRORE',
          text: err
        });
      });
      conn.on('close', (err) => {
        console.log(err);
      });
      conn.on('data', (data) => {
        this.action(data);
        console.log(data);
      });
      this.conn = conn;
    });
    peer.on('call', (call) => {
      call.answer(this.getStream(this.cliente.nativeElement));
      call.on('stream', (remotestream) => {
        this.cliente.nativeElement.srcObject = remotestream;
      });
      call.on('close', () => {
        Swal.fire({
          icon: 'info',
          title: 'Videochiamata terminata!'
        });
      });
      call.on('error', (err) => {
        console.log(err);
      });
    });
    return peer;
  }

@juliangorge
Copy link

Now it's working on Safari iOS but not Chrome iOS. my proj: https://edoctor-webapp.herokuapp.com/

@kojiro2ph
Copy link

kojiro2ph commented Apr 5, 2020

Now it's working on Safari iOS but not Chrome iOS. my proj: https://edoctor-webapp.herokuapp.com/

how did you solved this ?
my ios cant use peerJS and video call

@juliangorge
Copy link

Do you use HTTPS? are you on same NAT?

@kojiro2ph
Copy link

Do you use HTTPS? are you on same NAT?

yes. i use https

here is my demo

https://d3avcu2s7x6wu3.cloudfront.net/f/index.html

it works with PC but not with SP

@juliangorge
Copy link

juliangorge commented Apr 5, 2020 via email

@juliangorge
Copy link

I can access mic & camera and watch me on ios and macos but cannot connect

Check your log. You’ve got this error: [Error] Failed to load resource: the server responded with a status of 404 () (socket.iohttp://socket.io, line 0) https://d3avcu2s7x6wu3.cloudfront.net/socket.io/?EIO=3&transport=polling&t=N5AgvrZ Check this: https://stackoverflow.com/questions/46151327/keep-getting-socket-io-eio-3transport-pollingt-lvm1sgo-404-errors-when-i-de I fixed that putting on my domain:port on let io = io(‘https://domain:PORT/’https://domain:port/’) on app.js client. When I used heroku app, I didn’t need to do that, check and tell me. El 5 abr. 2020, a las 10:54, kojiro2ph <[email protected]mailto:[email protected]> escribió: with

@kojiro2ph
Copy link

kojiro2ph commented Apr 5, 2020

oh, i forgot to fix this error ><

i saw your original heroku
and i found that you use socket.io.js
so i include this into my app.js

but i saw your code but it seem
let socket = io()

are not used by any other places

do i need to use this?

image

@juliangorge
Copy link

juliangorge commented Apr 5, 2020 via email

@kojiro2ph
Copy link

i solved it !

the way is i changed the peerjs version 0.3 to 1.1.0 : P

https://d3avcu2s7x6wu3.cloudfront.net/f/test.html

now it works PC SP !

@qubit999
Copy link

qubit999 commented May 3, 2020

Use PeerJS version 1.1.0, then it will work on iOS Safari

Check here #662 (comment)

@afrokick afrokick reopened this Feb 20, 2022
@afrokick
Copy link
Member

As I know @afrokick is aware of the problem, and has even updated the docs to reflect the "only json" nature of Safari. However, I think, that we not only should inform the developers that they should use serialization = "json" for peerOptions to support Safari, we should allow binary format but for safari, fall back to a working approach in dataconnection.ts of the peerjs library.

Agree with you. I'll look at it again in the next versions.

@afrokick afrokick added platform-specific issues affecting only specific platforms confirmed acknowledged as an issue help wanted looking for contributors documentation need update some info in doc labels Feb 20, 2022
@irgalamarr irgalamarr added client related to peerjs client and removed help wanted looking for contributors client related to peerjs client labels Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed acknowledged as an issue documentation need update some info in doc platform-specific issues affecting only specific platforms
Projects
None yet
Development

No branches or pull requests

8 participants