如何在对等方不能互相信任时验证WebRTC连接信号?

时间:2016-04-21 21:36:55

标签: webrtc

我正在构建一个WebRTC应用程序,其中随机选择两个用户,然后相互连接以进行聊天。两个客户端都保持一个开放的WebSocket连接,我打算用它来交换他们的提议/答案以表示连接。我想要考虑的情况是,当有一个对等方故意发送错误的配置信息时,以及当对等方可能在信令交换中间自发断开时。

我对第一种情况的解决方案是让服务器保持交换状态,所以当首次建立连接时,我希望用户A提供优惠,而用户B有答案。这个合适吗?还是应该只在客户端实施?

我对第二个问题的解决方案对我来说就像一个黑客。我想要做的是通知用户已经进行了匹配,然后用户将超时设置为20秒,如果在该时间内没有建立连接则应该继续... < / p>

这些适当的解决方案吗?当两个对等体都不可信时,您如何可靠地建立WebRTC?信令服务器是否应关注交换状态?

1 个答案:

答案 0 :(得分:0)

Sounds like you're more concerned about call set up errors rather than being able to trust the identity of the remote peer. They are two very different problems.

Assuming it is the call set up errors you are concerned about you shouldn't be trying to avoid them you should be trying to make sure your application can handle them. Network connection issues are something that will always crop up and need to be handled.

Setting a timer for the establishment of a WebRTC call to complete is a logical solution. Displaying a warning to the user that the time limit is approaching also seems like a good idea. SIP is a signalling protocol and it has a defined timeout for the completion of a transaction and if it doesn't complete within that time it will generate an error response. You could use the same approach.