简体   繁体   中英

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. Project File Download

UPnP is enabled:

路由器的 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".
  • Added Project file download

Both UPnP is enabled on both routers, what was missing was the Firewall settings. 防火墙 I had to disable Both of the firewalls on the router settings to connect via the internet using the host's public IP address. ps. massive thanks to @nIcEcOw.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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