用于 Java 的 STUN、TURN、ICE 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2039147/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 19:04:45  来源:igfitidea点击:

STUN, TURN, ICE library for Java

javanatstunturn

提问by Hemeroc

I need to establish a P2P UDP and TCP Connection between two Users. Both of them are behind a NAT.

我需要在两个用户之间建立 P2P UDP 和 TCP 连接。它们都在 NAT 后面。

A little research leads me to STUN, TURNand ICE.

一些研究使我想到了 STUNTURNICE

Is there any Java solution (library) except jSTUNwhich seems to work only on UDP. And TURN, ICE is much better for the symmetric NAT Problem.

除了jSTUN似乎只适用于 UDP之外,是否有任何 Java 解决方案(库)。和 TURN,ICE 对于对称 NAT 问题要好得多。

回答by SplinterReality

Not to toot my own horn too much, but might I recommend trying IcedJava. (It's a part of the SipTools project) It's actively being developed, has a stable release 0.9 version, and supports use cases like RTP streaming out of the box.

不要吹嘘我自己的号角太多,但我可以推荐尝试IcedJava。(它是 SipTools 项目的一部分)它正在积极开发中,具有稳定的 0.9 版本,并支持开箱即用的 RTP 流等用例。

As far as TCP support, that's slated for a later release, but you're going to have a hard time supporting TCP over symmetric nat due to the three way handshake being blocked. Even the TCP extensions to the ICE specification note that TCP connections are much less likely to succeed than UDP connections between natted peers.

至于 TCP 支持,那将在以后的版本中发布,但是由于三向握手被阻止,您将很难通过对称 nat 支持 TCP。甚至 ICE 规范的 TCP 扩展也指出,TCP 连接比 natted 对等点之间的 UDP 连接成功的可能性要小得多。

That said, you can workaround this by routing TCP packets over a UDP bridge, including all of the error correction and flow control features. (I forget the RFC for this, but it is a final specification) Still, all of these are relatively new specifications, and the ICE-TCP spec is not yet final. Even in active development, these will take time to implement.

也就是说,您可以通过在 UDP 网桥上路由 TCP 数据包来解决此问题,包括所有纠错和流量控制功能。(我忘记了 RFC,但它是最终规范)不过,所有这些都是相对较新的规范,而且 ICE-TCP 规范尚未最终确定。即使在积极的开发中,这些也需要时间来实施。

回答by Paulo Fidalgo

There is also ice4j, which acording to the developers:

还有ice4j,根据开发人员的说法

A Java implementation of the STUN and TURN and ICE protocols. This project is a continuation of the Stun4J initiative. The goal of the project is to provide VoIP Java developers with a means of handling NATs and firewalls.

STUN、TURN 和 ICE 协议的 Java 实现。该项目是 Stun4J 计划的延续。该项目的目标是为 VoIP Java 开发人员提供一种处理 NAT 和防火墙的方法。

it's been developed by the sipcommunicator devs.

它是由 sipcommunicator devs 开发的。

回答by John

You could try jstunt- no longer maintained, but source seems to be available. They provide a jar with the STUNT library and example java server/client applications. From my reading, it's not native java, so this may only work on certain architectures.

您可以尝试jstunt- 不再维护,但源似乎可用。他们提供了一个带有 STUNT 库和示例 java 服务器/客户端应用程序的 jar。从我的阅读来看,它不是原生 java,所以这可能只适用于某些架构。