简体   繁体   English

Golang `pions` lib 示例问题

[英]Golang `pions` lib example issue

I've just started experimenting with WebRTC with Go and downloaded pions/webrtc library but I'am stuck with it's data-channels example.我刚刚开始用 Go 尝试 WebRTC 并下载了pions/webrtc库,但我坚持使用它的data-channels示例。

As it written in docs I opened jsfiddle client example .正如它在文档中所写的那样,我打开了jsfiddle 客户端示例

Then I'am running go run main.go command in the /go/src/github.com/pions/webrtc/examples/data-channels folder on my server to launch data-channel.然后我在服务器上的/go/src/github.com/pions/webrtc/examples/data-channels文件夹中运行go run main.go命令以启动数据通道。

After that I copy Browser base64 Session Description from jsfiddle example and paste it into my terminal where data-channels go script is running and it generates Golang base64 Session Description code which I paste into jsfiddle example and then press Sart session button.之后,我从 jsfiddle 示例复制Browser base64 Session Description并将其粘贴到我的终端中, data-channels go 脚本正在运行,它生成Golang base64 Session Description代码,我将其粘贴到 jsfiddle 示例中,然后按Sart session按钮。

And it fails to establish connection :(并且无法建立连接:(

This is my jsfiddle example for client side:这是我的客户端 jsfiddle 示例:

在此处输入图片说明

And this is my server side go script:这是我的服务器端 go 脚本:

在此处输入图片说明

What am I doing wrong?我究竟做错了什么?

Thanks for using pion-WebRTC (I am one of the developers!)感谢您使用 pion-WebRTC(我是开发人员之一!)


WebRTC uses a technology called ICE to allow peers to talk to each other. WebRTC 使用一种称为 ICE 的技术来允许对等方相互交谈。 Two peers exchange IP addresses via the SDP (the text you pasted) then they attempt to communicate by sending small UDP packets between each other.两个对等点通过 SDP(您粘贴的文本)交换 IP 地址,然后它们尝试通过在彼此之间发送小的 UDP 数据包来进行通信。 Once two IP addresses successfully communicate via ICE the rest of the WebRTC steps can continue.一旦两个 IP 地址通过 ICE 成功通信,其余的 WebRTC 步骤就可以继续。 For you this process is failing.对你来说,这个过程失败了。 I don't know how/why though.我不知道如何/为什么。 Firewalls, VPNs etc... all can cause problems.防火墙、VPN 等……都可能导致问题。

You will have to debug and check different scenarios.您将不得不调试和检查不同的场景。 I would try running the examples on your local PC.我会尝试在您的本地 PC 上运行这些示例。 If that works then maybe try between a different server.如果可行,那么也许可以在不同的服务器之间尝试。 A good tool to help here also is tcpdump that can show if UDP packets are arriving.在这里提供帮助的一个很好的工具是tcpdump ,它可以显示 UDP 数据包是否到达。 I usually use tcpdump -i any udp and inbound我通常使用tcpdump -i any udp and inbound


We also recently added IPv6 support, so might be worth trying from master and see if that helps at all!我们最近还添加了 IPv6 支持,因此可能值得大师尝试一下,看看是否有帮助! Hopefully this helps, but if you are still having issues feel free to ask more questions.希望这会有所帮助,但如果您仍有问题,请随时提出更多问题。 We are also all available via our Slack Channel you can sign up here here and would be more then happy to chat!我们也可以通过我们的Slack 频道联系您,您可以在这里注册,然后很乐意聊天!

I met similar problem, and I solved by我遇到了类似的问题,我解决了

echo $BROWSER_SDP |回声 $BROWSER_SDP | ./main 。/主要的

BROWSER_SDP is the session description in your browser, main is the exe by go build main.go(you can rename exe by mv). BROWSER_SDP 是浏览器中的会话描述,main 是通过 go build main.go 生成的 exe(您可以通过 mv 重命名 exe)。 This can make sure transfer SDP to the server, which is really important.这可以确保将 SDP 传输到服务器,这非常重要。

The detail 细节

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

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