Cannot connect to clients when behind a VPN

This is for troubleshooting of problems with the FAF client and Forged Alliance game.

Moderator: PhilipJFry

Cannot connect to clients when behind a VPN

Postby ashpool » 07 Jun 2018, 15:27

Most of the time I use public networks at my campus where it's not possible to forward a port. However, I have set up a VPS with a public IP and I have OpenVPN running on it. Using firewalld and masquerade I have set up my own PC to route all traffic via the server, and it works. I have also set up the 6112/udp port on the server's public address to be forwarded to my machine's internal VPN address, and ensured there were no local firewalls preventing incoming connections. I tested this using the ncat utility and had successfully received and sent UDP packets on my local machine port 6112 from and to a third party server. UPnP is disabled in client settings, as my VPS doesn't support it.

HOWEVER, each time I join a lobby, there're always 1-3 people on the list I can't connect to. It just says "Connecting to ***..." forever. ReFAFing doesn't seem to work for neither me nor them. I have tried switching to the port 7712/udp and still had no luck. I always get kicked and that really annoys me.

Attached are the logs which contain records for my last few attempts to play a game. It can be seen that connection state is PUBLIC in all cases. I would like to hear some suggestions on what could possibly go wrong in such a scenario. I can probably fix the problems myself, I just want them pointed out, as I don't know all the technical details of how FAF connects to other players.
Attachments
game_logs.zip
(69.63 KiB) Downloaded 32 times
forever.log
(171.54 KiB) Downloaded 37 times
User avatar
ashpool
 
Posts: 4
Joined: 07 Jun 2018, 14:58
Has liked: 0 time
Been liked: 0 time
FAF User Name: ashpool

Re: Cannot connect to clients when behind a VPN

Postby ashpool » 08 Jun 2018, 03:14

So after poking around a little, I discovered that Supcom for some reason has been using a wrong port for communications. There were indications of this in the game log files, and I confirmed it with the help of ProcessMonitor. What's interesting is that the actual port number to be used was the set port number +1. E.g. when the port set in FAForever was 6112, the supcom would actually use 6113, 7712 -> 7113 and so on.
My logical solution was just decrementing the port number by 1, and that seemed to have done the trick. After setting the port number to 6111 supcom would now use the port 6112 I wanted it to. But players would still fail to connect. So I took another look on the forever.log file, and found out that the client (or whatever is writing to forever.log) was attempting to use the port 6111, which wasn't forwarded, and obviously the connectivity state would become STUN. Not willing to put an awful lot of thought in it, I just forwarded the port 6111 on my VPS as well. Did that help? Nope. I'll keep you updated.
I'd like to point out that a similar issue has been discussed here viewtopic.php?t=15705&p=159070 but no solution was found.
User avatar
ashpool
 
Posts: 4
Joined: 07 Jun 2018, 14:58
Has liked: 0 time
Been liked: 0 time
FAF User Name: ashpool

Re: Cannot connect to clients when behind a VPN

Postby ashpool » 10 Jun 2018, 05:14

I'm beginning to understand how FAF client works after studying the source code a little. What I now know is that the incremented port I wrote above about is actually a result of correct behavior where FAF uses it to communicate with the game and forward commands.
Another thing has now attracted my attention. In the forever.log file I found lines like these:

Code: Select all
2018-06-10 05:18:08,454 INFO     client.connection              Outgoing JSON Message: {"command": "InitiateTest", "target": "connectivity", "args": [6112]}
2018-06-10 05:18:11,447 INFO     client.connection              Outgoing JSON Message: {"command": "ProcessNatPacket", "target": "connectivity", "args": ["10.42.0.1:194", "Are you public? 182983"]}
2018-06-10 05:18:11,447 INFO     connectivity.helper.ConnectivityHelper Unknown natpacket
2018-06-10 05:18:11,447 INFO     client.connection              Outgoing JSON Message: {"command": "ProcessNatPacket", "target": "connectivity", "args": ["10.42.0.1:194", "Are you public? 182983"]}
2018-06-10 05:18:11,448 INFO     connectivity.helper.ConnectivityHelper Unknown natpacket
2018-06-10 05:18:11,448 INFO     client.connection              Outgoing JSON Message: {"command": "ProcessNatPacket", "target": "connectivity", "args": ["10.42.0.1:194", "Are you public? 182983"]}

at the beginning of every game session. Now 10.42.0.1 is a gateway node in my VPN, and it most definitely does not listen for anything at port 194. These IP and port are always the same for any game session.
What's more, I see connection attempts to some clients (where it says "Hello from...") on address 10.42.0.1 and a random port, while for others their real IP is used. There's no correlation between this and the clients being unreachable in a fashion described in the original post.
This may be the problem. I will look further into the source code to try and locate its root.
User avatar
ashpool
 
Posts: 4
Joined: 07 Jun 2018, 14:58
Has liked: 0 time
Been liked: 0 time
FAF User Name: ashpool

Re: Cannot connect to clients when behind a VPN

Postby Wesmania » 10 Jun 2018, 18:55

I'll just butt in to say that I greatly appreciate delving into the source code to fix this stuff :D
Wesmania
Contributor
 
Posts: 391
Joined: 19 Nov 2014, 19:17
Has liked: 2 times
Been liked: 79 times
FAF User Name: MazorNoob


Return to Tech Support

Who is online

Users browsing this forum: No registered users and 1 guest