problem with LAN connection enet udp

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
stepps
Prole
Posts: 19
Joined: Mon Feb 08, 2021 8:57 pm

problem with LAN connection enet udp

Post 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 174 times
User avatar
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

Re: problem with LAN connection enet udp

Post 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
User avatar
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

Re: problem with LAN connection enet udp

Post 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
User avatar
togFox
Party member
Posts: 779
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: problem with LAN connection enet udp

Post by togFox »

The OP title says .'LAN' but OP post says not LAN.

I'm confused and maybe others are too.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: problem with LAN connection enet udp

Post 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.
User avatar
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

Re: problem with LAN connection enet udp

Post 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
User avatar
togFox
Party member
Posts: 779
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: problem with LAN connection enet udp

Post by togFox »

Let me know if you get this to work on the big bad internet ie not (LAN).
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

Re: problem with LAN connection enet udp

Post 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.
User avatar
togFox
Party member
Posts: 779
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: problem with LAN connection enet udp

Post 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.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

Re: problem with LAN connection enet udp

Post 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).
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 210 guests