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:
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:
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.