Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] UDP and firewall?

Author
Message
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 10th Jan 2019 15:05
Hey How will UDP work with a firewall? I've been using sockets and regular networks messages, these can connect to host through a firewall because they connect to an IP address and a specified port which makes the firewall allow communication back to the client by routing the used port in the firewall. But with UDP, an UDP listener is created on both ends, how will I know which port the firewall routed to the port on the client?
13/0

The author of this post has marked a post as an answer.

Go to answer

Paul Johnston
TGC Developer
16
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 10th Jan 2019 15:18
This post has been marked by the post author as the answer.
If you can get a packet from one client to the other then you can take the source port of the packet and use that as the destination port in the reply and the firewall will remember the source port it used and forward it back to the sender. However it does require that you can send packets one way to begin with, such as with port forwarding. If both clients have firewalls without port forwarding then a third party server is needed to negotiate the connection.
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 10th Jan 2019 15:48
I already have a lobby server running 24/7 which also detects the IP of all connecting to it How do I get the source port from a packet? (Ah, I had not seen this command: GetNetworkMessageFromPort) Let me extend a thank you for all you and your coworkers' hard work, your products make it very easy to develop games from scratch. I have even sat down one evening to make some mockup graphics of how an app I would like to make could look like, one thing led to another and 3 AM in the morning I had a fully working app.
13/0
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 11th Jan 2019 09:13
How do I negotiate the connection between two clients if they are both behind a firewall/NAT? Doesn't the firewall route the IP that the client sends to, and assigns a port that will route to the client? Or can I just send to the lobby server IP, read the port on the packet arrived at the lobby server, then tell the other client to use that port even though the client will send from an other IP address?
13/0
Paul Johnston
TGC Developer
16
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 11th Jan 2019 14:47
It depends on the firewall, there are versions that will only allow the specific IP and port combo to forward packets back to the sender behind the firewall, called symmetric NAT, however I think these are rare. The method you describe should work in other cases.
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 25th Mar 2019 10:37 Edited at: 25th Mar 2019 12:48
I have a problem reading the right port now, it seems like the server reads to the original port from the sending computer, not the one assigned by the firewall.

EDIT The port read on the server is identical to the port on the sending computer, connecting to that port does not work but if I port forward the same port as the computer is sending from then I can connect (so that the port the firewall uses becomes the exact same port as the computer uses). When receiving the message on the server, I use the GetNetworkMessagePort() on the UDP message, and it is here that the original port is read, not the firewall assigned port. There are more details in the following message (Tier 2, Linux, console app).
13/0
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 25th Mar 2019 11:57
This is a Tier 2 Linux console app, btw, that reads the original port used, not the firewall port. I use CreateNetworkMessage() and SendUDPNetworkMessage().
13/0
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 25th Mar 2019 21:14
The first time today where I ran another part of the project using an online server, it reported the right port from the firewall the first time, subsequently, the original port on the sending PC was reported. I have tried a full powercycle of all units at my location, but that didn't help, I will test again tomorrow to see if the port is reported right on the day's first run. It might be my firewall that is causing this, I will test more.
13/0
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 26th Mar 2019 08:41
Well, I tested again today but GetNetworkMessagePort() will only report the original port used on the sending computer, not the port assigned by the firewall. Does anybody have any idea of what could be going on here?
13/0
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 27th Mar 2019 10:56
Connecting a second client does indeed give me another port on the firewall, so again, it is a me problem I have a whole lot of problems right now, I am sorry if I caused any of you inconvenience by testing this!
13/0

Login to post a reply

Server time is: 2019-06-24 11:09:41
Your offset time is: 2019-06-24 11:09:41