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

Error when sending RN #642

Open
henworx-angelone opened this issue Apr 3, 2020 · 3 comments
Open

Error when sending RN #642

henworx-angelone opened this issue Apr 3, 2020 · 3 comments
Labels
client related to peerjs client

Comments

@henworx-angelone
Copy link

henworx-angelone commented Apr 3, 2020

So far Peer.js works in react-native. I have only the problem as soon as I want to send a message that the connection is broken and gives me the following error:

DC #: dc_6igjvuv7fhg Error when sending: (TypeError) Data must be either string, ArrayBuffer, or ArrayBufferView.

Tested with RN 6.0.0 - 6.2.0.

In addition, although I can establish a connection, I do not get feedback from the connection.

    localPeer.on('connection', conn => {
      conn.on('open', () => {
        console.log(conn.dataChannel);
        conn.on('data', data => {
          console.log(data);
            conn.send("String");
        });
        console.log(conn.dataChannel);
      });
    });

     var conn = localPeer.connect ('he8b');
     console.log (conn);
     conn.on ('open', () => {
       console.log ("works"); // THIS NOT WORKS NOW!
     });

I don't have these problems in the browser.

My installed packages:

     "js-binarypack": "0.0.9",
     "ns-binarypack": "0.0.5",
     "peerjs": "^ 1.2.0",
     "peerjs-js-binarypack": "^ 1.0.1",
     "react": "16.11.0",
     "react-native": "0.62.0",
     "react-native-incall-manager": "^ 3.2.7",
     "react-native-peerjs": "^ 1.0.4",
     "react-native-webrtc": "^ 1.75.3"

when i send a message from the browser it also arrives, but only when i start the connection from the browser

@akshaya-rao-s
Copy link

Did you solve this? I am still having this issue.

@wfmarques
Copy link

So is not a fix but for my case forcing the connection serialization type to "json" works.

let conn = this.peer.connect(destPeerId)
conn.serialization = "json"

@irgalamarr irgalamarr added the client related to peerjs client label Feb 24, 2024
@compojoom
Copy link

Did you ever manage to solve this? I'm running into the same error, but if I set serialization to "json" brings up:
SyntaxError: JSON Parse error: Unexpected character: o

If I do serialization: none, then I'm able to receive a message from web and run it through Buffer.from(data).toString(), sending doesn't crash, but the client(the web app) receives 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client related to peerjs client
Projects
None yet
Development

No branches or pull requests

5 participants