最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I use WebRTC to open a UDP connection? - Stack Overflow

programmeradmin1浏览0评论

We need send data to our users' devices using the TFTP protocol, which is a simple FTP-like protocol that works over UDP.

Since we can't open a UDP socket using javascript, we have been using our server as a proxy, sending the data to our server and opening a UDP connection from the server to the device. That does have the drawback that our users need to learn about NAT and configure port forwarding.

So the question is, could we use WebRTC to open a direct UDP socket to send and receive between the browser and the devices?

suggests that we could send some raw UDP data over the socket (that is, if it's possible to access that layer over javascript. i'm not sure about that), but I see no way to fetch a raw UDP response.

Any help much appreciated

We need send data to our users' devices using the TFTP protocol, which is a simple FTP-like protocol that works over UDP.

Since we can't open a UDP socket using javascript, we have been using our server as a proxy, sending the data to our server and opening a UDP connection from the server to the device. That does have the drawback that our users need to learn about NAT and configure port forwarding.

So the question is, could we use WebRTC to open a direct UDP socket to send and receive between the browser and the devices?

http://www.webrtc.org/reference/webrtc-internals/vienetwork#TOC-SendUDPPacket suggests that we could send some raw UDP data over the socket (that is, if it's possible to access that layer over javascript. i'm not sure about that), but I see no way to fetch a raw UDP response.

Any help much appreciated

Share Improve this question edited Dec 11, 2012 at 11:49 Florian Margaine 60.7k15 gold badges93 silver badges120 bronze badges asked Dec 11, 2012 at 0:46 tzikistzikis 1331 gold badge1 silver badge5 bronze badges 2
  • 26 I should tell you my new UDP joke, but.. you might never get it. – jAndy Commented Dec 11, 2012 at 0:50
  • I hope this article might help a lot. How to send a UDP Packet with WebRtc? – Muhammad Usman Bashir Commented Nov 19, 2021 at 18:57
Add a comment  | 

2 Answers 2

Reset to default 13

No. There are too many security issues allowing WebRTC to send to a random address/port - we have to make sure it doesn't work as a DDOS platform, so we require the target to implement ICE as an implicit permission to send data, and we also don't allow sending arbitrary data, just SRTP mediastreams and data in DataChannels (over SCTP over DTLS over UDP+ICE).

No, you cannot send raw UDP data using WebRTC like that.

The ViENetwork lib where you can find the SendUDPPacket method is used inside Chrome to handle packet transmissions, Windows QoS support and other network settings, but you don't have direct access to it.

One of the main features of WebRTC is the Data Channel that will bring the possibility to establish a peer-to-peer connection between two browsers, to allow raw data to be exchanged. This is still under construction in Chrome and Firefox as you can see here.

This can be what you are searching for, as you can establish a connection to send raw data and you will only have to worry in find a way to establish this connections to your other endpoint, if that's what you want.

发布评论

评论列表(0)

  1. 暂无评论