无法初始化对等连接,因为'cyclical structure in JSON object'



我正在尝试创建一个这样的对等连接:

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

但是我总是得到一个cyclical structure in JSON object错误。

即使我只使用url: ["stun:stun1.l.google.com:19302",…]而没有用户名和凭据,也会出现同样的错误。

我正在使用expo,但项目被弹出并使用XCode运行。

我该怎么做,有人能帮忙吗?

我不确定data来自哪个来源,但您应该验证s.uri,s.usernames.credential确实是字符串。它们中至少有一个似乎是一个对象。

我创建了一个新的项目,它工作了。数据来自后端仍相同或我创建了对等的方式连接。这个问题可能是一个依赖版本问题,因为我使用了其他版本的一些软件包,但我不确定。

最新更新