Page 1 of 2

problem with LAN connection enet udp

Posted: Mon Dec 13, 2021 2:31 am
by stepps
I attached the sample code.

It works if client is localhost and I run client and server on same machine.
But, as soon as I try to run client as ipv4 address (192.168,etc) and on
different machines (server on desktop and client on laptop for example), it doesn't work.

I already ruled out router/PC/firewall problems, because I can do LAN on Love2D for
some other projects/games out there, so that's not the issue. That means only problem
is I am not doing something correct with the code, I am missing something or what?

Thanks guys!
enetTest.zip
(1.06 KiB) Downloaded 193 times

Re: problem with LAN connection enet udp

Posted: Mon Dec 13, 2021 12:00 pm
by EngineerSmith
Honestly looking through the code, all is fine and it should work. Therefore it would be a network issue with a firewall. On windows make sure the love.exe has access through private and public networks for inbound and outbound connections.

I'm on Android right now, but I'll have a look to see if I can run the code when I'm on windows next

Re: problem with LAN connection enet udp

Posted: Mon Dec 13, 2021 8:15 pm
by EngineerSmith
(I said this on discord, but for others interested)
The code works perfectly on my machine across a private (and public) network when I tested it. So the issue would lie with a firewall blocking the UDP packets either coming into the server, or out of the server

Re: problem with LAN connection enet udp

Posted: Mon Dec 13, 2021 9:41 pm
by togFox
The OP title says .'LAN' but OP post says not LAN.

I'm confused and maybe others are too.

Re: problem with LAN connection enet udp

Posted: Mon Dec 13, 2021 10:21 pm
by pgimeno
togFox wrote: Mon Dec 13, 2021 9:41 pm The OP title says .'LAN' but OP post says not LAN.
OP post says LAN too. It says that it works with server and client in the same machine but not between machines in a LAN.

Works for me between Linux machines in a LAN, too.

Re: problem with LAN connection enet udp

Posted: Tue Dec 14, 2021 5:01 pm
by EngineerSmith
For others who aren't on discord, the issue was resolved. They were using the client's own private ip rather than using the server's machine private ip when trying to connect

Re: problem with LAN connection enet udp

Posted: Wed Dec 15, 2021 4:09 am
by togFox
Let me know if you get this to work on the big bad internet ie not (LAN).

Re: problem with LAN connection enet udp

Posted: Wed Dec 15, 2021 11:10 am
by EngineerSmith
togFox wrote: Wed Dec 15, 2021 4:09 am Let me know if you get this to work on the big bad internet ie not (LAN).
If it works on LAN, it works on WAN. It is just a different IP (server's public ip) and port forwarding on the router to the private ip

Edit: How the internet works:
Instead of each machine on the internet having a public IP (because we would run out of them) we just give each router a public IP. The router the acts like a switch between the private network and the public network using NAT (Network address translation). Port forwarding just tells the router how to translate(redirect) a public port to a machine's port that within it's private network.

Re: problem with LAN connection enet udp

Posted: Wed Dec 15, 2021 1:01 pm
by togFox
I use sock.lua and it works fine on local server and fine on LAN but not on internet.

I think I've done port forwarding, I think I've done firewalls, I think I've used external IP yet it doesn't work so - sure - I might have done something wrong, but others say UDP and NAT punch-through is hard.

So, if anyone can get this to work it would form a great baseline and a point of reference for me to troubleshoot.

Re: problem with LAN connection enet udp

Posted: Wed Dec 15, 2021 1:11 pm
by EngineerSmith
By LAN is the client connecting to the private ip of the server machine? 192.168.*.* or 10.0.0.*, or are you using localhost to connect to the server. Make sure the address for the server is

Code: Select all

*
as I've had issues where

Code: Select all

localhost
only works on that machine and not on the private network (Which makes sense why localhost only works locally).