简体   繁体   English

WebRTC数据通道服务器向客户端进行UDP通信。目前有可能吗?

[英]WebRTC Data Channel server to clients UDP communication. Is it currently possible?

Is it possible to use WebRTC Data Channels on Node.js in a way that mimics the functionality of WebSockets except using UDP? 是否可以在Node.js上使用WebRTC数据通道,以模仿除了使用UDP之外的WebSockets的功能?

In essence I want to have a server running Node.js with which browser clients can establish a full duplex bi directional UDP connection via JavaScript. 本质上,我希望有一个运行Node.js的服务器,浏览器客户端可以通过JavaScript建立全双工双向UDP连接。

My question is the same as this one from 8 months ago. 我的问题是一样的这一个从8个月前。 I repost it because the only answer was : 我重新发布它是因为唯一的答案是:

Yes, in theory you should be able to to do this. 是的,理论上你应该能够做到这一点。 However, you'll need a node module that supports WebRTC data channels, so that you can connect to it like any other peer. 但是,您需要一个支持WebRTC数据通道的节点模块,以便您可以像任何其他对等方一样连接到它。 Unfortunately, scanning through the current modules, I don't see one that implements the data channel. 不幸的是,扫描当前模块,我没有看到实现数据通道的模块。

Any of you know of such a module ? 你们谁知道这样的模块? In my search I found some node modules with the words "webrtc" and "datachannel", but they didn't look like what was needed, they looked like they were meant for specific needs. 在我的搜索中,我发现了一些带有“webrtc”和“datachannel”字样的节点模块,但它们看起来并不像需要的东西,它们看起来像是出于特定需求。

This project is very active, and seem to undertake the mission of importing the entire WebRTC stack into node.js There's also this project but it looks pretty inactive. 这个项目非常活跃,似乎承担了将整个WebRTC堆栈导入node.js的任务。还有这个项目,但它看起来非常不活跃。

Would love to know if that was satisfying and if you're doing such a project (as in the question) please link to github :) 很想知道这是否令人满意,如果你正在做这样的项目(如在问题中)请链接到github :)

We have implemented the exact same thing: a server/client way of using WebRTC. 我们实现了完全相同的东西:服务器/客户端使用WebRTC的方式。 Besides we also implemented data port multiplexing, so that server would only need to expose one data port for all rtcdata channels. 此外,我们还实现了数据端口多路复用,因此服务器只需要为所有rtcdata通道公开一个数据端口。

A quick summary of how it is achieved: 快速总结如何实现:

  • We implemented in nodejs, using wrtc library. 我们使用wrtc库在nodejs中实现。 But the same principal could be applied to other implementations. 但是同样的原则可以应用于其他实现。
  • The server exposes a control port, so that the client will exchange SDPs with the server for establishing their data channel. 服务器公开控制端口,以便客户端与服务器交换SDP以建立其数据通道。
  • To support data port multiplexing, At the server, we modify both peer's SDK, so that 为了支持数据端口多路复用,我们在服务器上修改了对等的SDK,以便这样做
    1. Client will always connect to the same server ip:data_port 客户端将始终连接到同一服务器ip:data_port
    2. We implement a UDP data proxy inside the server, so that it can be the bridge between the server webrtc engine and the client. 我们在服务器内部实现UDP数据代理,这样它就可以成为服务器webrtc引擎和客户端之间的桥梁。

The code is at: https://github.com/noia-network/webrtc-direct 代码位于: https//github.com/noia-network/webrtc-direct

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM