H.Gndgn
H.Gndgn

Reputation: 87

Cannot initialize a peer connection, because of 'cyclical structure in JSON object'

I am trying to create a peer connection like this:

const iceServers: RTCIceServer[] = data.iceServers.map((s) => {
  return {
    urls: [s.uri],
    username: s.username,
    credential: s.credential,
  };
});

const configuration: RTCConfiguration = {
  iceServers: iceServers,
};

const conn = new RTCPeerConnection(configuration); <-- here comes the error

But I get always an cyclical structure in JSON object error.

The same error occurs even if I am only using urls: ["stun:stun1.l.google.com:19302",..] without username and credential.

I am using expo, but the project is ejected and running using XCode.

How can I proceed can someone help?

Upvotes: 0

Views: 184

Answers (2)

H.Gndgn
H.Gndgn

Reputation: 87

I created a new fresh project and it worked. The data which comes from backend was still the same or the way I created the peer connection. The problem could be probably a dependency version issue, since I used other versions for some packages but I am not sure.

Upvotes: 0

Ivan
Ivan

Reputation: 778

I'm not sure from which source data comes from, but you should validate that s.uri, s.username and s.credential are strings indeed. At least one of them seems to be an object instead.

Upvotes: 1

Related Questions