Manually port forwarding works, UPnP port forwarding does not

153 views Asked by At

I'm writing a simple p2p chat program using TcpListener and TcpClient in C#. In my local network, the connection succeeds. But I have some problems establishing a connection through the internet.

To establish a connection through the internet I first set up port forwarding manually in the settings of my router. Then my Server Program connects to the IP of my router and the Client from outside of my local network, connects to my external IP. The connection succeeds.

Now I can't expect the user to manually set up port forwarding, so I wanted to use UPnP Port forwarding. My Server Program seems to set up UPnP Port forwarding correctly. In the settings of my router I can see that an entry for UPnP Port forwarding was created. I've expected it to work exactly like the manually set up Port forwarding. My Server Program connecting to the IP of the router and the Client connection to my external IP. But it always end with error 10061, saying that the target computer has rejected the connection.

Now I can't seem to find any information on that issue. Can someone please give me a hint to what I'm missing, or how I can find out where the problem exactly is? I'm just really confused why it doesn't work with UPnP, but with a manually set up port forwarding. Are there any differences?

0

There are 0 answers