Enable port on a mobile device

Hello,

I’m working on a multi-player game where devices communicate like this device1 <> SERVER <> device2. Meaning that device1 sends data to SERVER and then SERVER sends data to device2. I’m using udp protocol for this. Everything is working well while I use local IP, but when I use public IP - problems occur. Clients (mobile devices) use port 8283 to LISTEN / WAIT for data from the server however, this only works on local, on public it doesn’t - obviously because I’d need to ‘somehow’ enable port 8283 on mobile devices so the server may send data to their public IP and so they (mobile devices) accept it.

So, I’m wondering what would be Your solution here? How should I enable specific port on mobile device so it can listen to the server and receive data using public IP?

Best regards,

Tomislav

The problem you are facing is a complex one :slight_smile:

To enable a peer-2-peer type system to bypass firewalls you need to create a “bridge” “unless of course there is no firewall” :slight_smile:

So in short terms it is something like this (or at least this is have I have done it in the past (like 8 years ago that is)…

Have a server that accepts connections from “everyone”

Client A wants to connect to Client B

So they both connect to the server and then the server “bridges” the connection between ClientA and ClientB (like a proxy)

That is the only way to do it when firewalls are in effect, however if firewalls are not an issue then you can simple do something along the lines of socket::listen(ip, port) on each of the clients then give each client the correct ip address.

Keep in mind that UDP will not work for this type of p2p logic.

Thanks for the reply.

Could You please clarify and point me in the right direction?

I think I got You about building “bridge” so let me try to explain further more.

I’m working on a turn based 1v1 online game which includes match-making. So I have a server which creates an instance of ‘match’ class for every match (I’m only pointing this out so You’d understand why did I decide to use this kind of communication structure). The server also includes a listener class which receives data (on a specific port) from players and also sends data to them (mobile devices). So once again, it looks like this: device1 <data> SERVER(listener) <data> device2. Therefore the server receives data from device1 and then (the server) sends data to device2 or vice versa. So in here, the server (listener) would be a bridge like You said. I configured the server so it may receive data on a specific port (portforwarding) - naturally, the server receives data when I send it to the server’s public IP, however, clients don’t receive data when I send it to their public IP and that’s my problem - why don’t clients (mobile devices) receive data (well, I do know an answer to that but how should I fix it)?

The server listener, listener on mobile devices, match-making - it’s all done and tested locally (where it works), however testing on public causes problems on client-side (not receiving data).

As for not using UDP protocol - I also thought this might be a problem so I tried switching to TCP but it doesn’t work either (I get a message “No connection could be made because the target machine actively refused it.”).

I know I’m missing something in the whole story but I’m just not sure what would it be? -is it a method I use or something else?

I don’t want players to turn their firewall off or whatsoever - I want them to install the game and be able to play it online straight away just like people install Skype and may chat immediately.

Best regards,

Tomislav

Right, so what I’m looking for is hole punching, if anybody has any experience with it in lua

best regards

The problem you are facing is a complex one :slight_smile:

To enable a peer-2-peer type system to bypass firewalls you need to create a “bridge” “unless of course there is no firewall” :slight_smile:

So in short terms it is something like this (or at least this is have I have done it in the past (like 8 years ago that is)…

Have a server that accepts connections from “everyone”

Client A wants to connect to Client B

So they both connect to the server and then the server “bridges” the connection between ClientA and ClientB (like a proxy)

That is the only way to do it when firewalls are in effect, however if firewalls are not an issue then you can simple do something along the lines of socket::listen(ip, port) on each of the clients then give each client the correct ip address.

Keep in mind that UDP will not work for this type of p2p logic.

Thanks for the reply.

Could You please clarify and point me in the right direction?

I think I got You about building “bridge” so let me try to explain further more.

I’m working on a turn based 1v1 online game which includes match-making. So I have a server which creates an instance of ‘match’ class for every match (I’m only pointing this out so You’d understand why did I decide to use this kind of communication structure). The server also includes a listener class which receives data (on a specific port) from players and also sends data to them (mobile devices). So once again, it looks like this: device1 <data> SERVER(listener) <data> device2. Therefore the server receives data from device1 and then (the server) sends data to device2 or vice versa. So in here, the server (listener) would be a bridge like You said. I configured the server so it may receive data on a specific port (portforwarding) - naturally, the server receives data when I send it to the server’s public IP, however, clients don’t receive data when I send it to their public IP and that’s my problem - why don’t clients (mobile devices) receive data (well, I do know an answer to that but how should I fix it)?

The server listener, listener on mobile devices, match-making - it’s all done and tested locally (where it works), however testing on public causes problems on client-side (not receiving data).

As for not using UDP protocol - I also thought this might be a problem so I tried switching to TCP but it doesn’t work either (I get a message “No connection could be made because the target machine actively refused it.”).

I know I’m missing something in the whole story but I’m just not sure what would it be? -is it a method I use or something else?

I don’t want players to turn their firewall off or whatsoever - I want them to install the game and be able to play it online straight away just like people install Skype and may chat immediately.

Best regards,

Tomislav

Right, so what I’m looking for is hole punching, if anybody has any experience with it in lua

best regards