简体   繁体   English

使用 Mirror 框架 PortMapping UPnP (Mono.Nat) 后仍然无法通过 Internet 连接

[英]Still cannot connect through Internet even after PortMapping UPnP (Mono.Nat) with the Mirror framework

Even after PortMapping (using Mono.Nat) connecting with the host's public IP address via Mirror from one Network to other networks through the internet doesn't work.即使在端口映射(使用 Mono.Nat)通过镜像从一个网络通过互联网连接到主机的公共 IP 地址之后,它也不起作用。 Project File Download 项目文件下载

UPnP is enabled: UPnP已启用:

路由器的 UPnP 设置,游戏在此处列出了 TCP 和 UDP

I don't think the problem is inside the script because the port is already opened in the router settings.我认为问题不在脚本内部,因为该端口已在路由器设置中打开。 The script for PortMapping:端口映射的脚本:

private void DeviceFound(object sender, DeviceEventArgs args)
{
    Debug.Log("1");
    INatDevice device = args.Device;
    Debug.Log("2");
    Mapping map = new Mapping(Protocol.Tcp, 7777, 7777);
    Mapping map2 = new Mapping(Protocol.Udp, 7777, 7777);
    Debug.Log("3");
    device.CreatePortMap(map);
    device.CreatePortMap(map2);
    Debug.Log("4");
    int test = device.GetAllMappings().Length;
    Debug.Log(test);
    foreach (Mapping portMap in device.GetAllMappings())
    {
        Debug.Log("5");
        Debug.Log(portMap.ToString());
    }
}
private void DeviceLost(object sender, DeviceEventArgs args)
{
    INatDevice device = args.Device;
    Mapping map = new Mapping(Protocol.Tcp, 7777, 7777);
    Mapping map2 = new Mapping(Protocol.Udp, 7777, 7777);
    device.DeletePortMap(map);
    device.DeletePortMap(map2);

}

Edit:编辑:

  • Added Mirror Documentations in the first paragraph.在第一段中添加了镜像文档。 you can find about Tcp/Udp in "Transports".您可以在“传输”中找到有关 Tcp/Udp 的信息。
  • Added Project file download添加项目文件下载

Both UPnP is enabled on both routers, what was missing was the Firewall settings.两个路由器都启用了 UPnP,缺少的是防火墙设置。 防火墙 I had to disable Both of the firewalls on the router settings to connect via the internet using the host's public IP address.我必须禁用路由器设置上的两个防火墙才能使用主机的公共 IP 地址通过互联网连接。 ps.附言。 massive thanks to @nIcEcOw.非常感谢@nIcEcOw。

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

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