greggman / HappyFunTimes

A System for creating 10-100+ player local games
http://greggman.github.io/HappyFunTimes
BSD 3-Clause "New" or "Revised" License
381 stars 55 forks source link

wifi connection not working on ip6 router #17

Closed YinYin-Falcon closed 8 years ago

YinYin-Falcon commented 8 years ago

Browser controllers on the same machine as the game work. Mobile phones in the same WiFi network don't ("Could not find HappyFunTimes").

greggman commented 8 years ago

Hey so just FYI I'm trying to figure out ipv6 support. It might only be a few lines of code. I'm also not 100% sure that is the problem you're running into but I do know the the current version does not run over ip6. It looks like it's only a few lines of code to fix I'm just trying to find the right lines.

If you feel like helping out there's several things you could try that would really help me narrow down the issue.

Could you run happyfuntimes on your machine, then open a browser on the same machine and go to http://docs.happyfuntimes.net/debug-hft-net.html

Then copy and paste the result here?

YinYin-Falcon commented 8 years ago

Sure thing: [ "192.168.0.2:18679" ]

It wouldn't be the first time I've run into missing ip6 support if that's it. Hope you don't have too many lines that require adjustments ;)

Also interestingly enough it works if I enter the above output in the phone browser.

greggman commented 8 years ago

If you go to http://docs.happyfuntimes.net/debug-hft-net.html on the phone what does it say?

YinYin-Falcon commented 8 years ago

Just empty brackets [ ]

greggman commented 8 years ago

Can you try both your PC and your phone again here http://docs.happyfuntimes.net/debug-hft-net.html

Note it should return an JSON answer like this now instead of an array

{
  "gameIps": [
    "10.27.29.45:18679"
  ],
  "publicIps": [
    "103.5.140.139"
  ]
}

If it still just returns an array for you try refreshing or if that doesn't work you might have to clear your cache.

YinYin-Falcon commented 8 years ago

PC: { "gameIps": [ "192.168.0.2:18679" ], "publicIps": [ "95.90.234.0" ] } phone: { "gameIps": [], "publicIps": [ "2a02:8109:8380:116c:c1c0:5aaf:43d2:483a", "66.249.93.86" ] }

greggman commented 8 years ago

So I'm still a network noob but it doesn't look like the phone and the computer are on the same wifi/router. Are they?

greggman commented 8 years ago

I should be clear, HappyFunTimes doesn't work on many corporate networks. It also doesn't work at places like Starbucks or other coffee shop cafes. It only works on standard home routers. The phone and the computer need to be able to talk directly to each other. There's no server on the outside to relay messages as that would be expensive and slow.

YinYin-Falcon commented 8 years ago

It's a home cable router that doesn't support/use ipv4 - afaik the public non v6 ips are handled by my isp, but I'm a network noob too :p

How could I quickly check if my android can talk to the PC? Because notebooks in the same network via wifi can talk to the PC.

edit: I've used some wifi remote apps on the android before to directly control the PC. Maybe I'll try to check if that also works via wifi without internet connection.

greggman commented 8 years ago

Well the first thing you could try is typing in the ipv4 address into your phone

Run happyfuntimes, it should say something like

 using ip address: 192.168.0.2.

Then your phone open a browser and type http://192.168.0.2:18679 (or whatever IP address happyfuntimes shows).

Please tell me if that works

If that works the next step is for me to upload a new version of happyfuntimes that will try to report the ipv6 address of happyfuntimes to happyfuntimes.net. I have a version that does that. Maybe that will solve it.

Otherwise I might have to resort to asking the user to enter a code if it can't find the game 😢 So the game would have to display "go to happyfuntimes.com and enter code 5 6 1 4 2 3" somewhere which would kind of suck. (you'd have to keep that code visible constantly so players can join at anytime). I hope I don't have to go there.

greggman commented 8 years ago

Are you on windows, linux, or OSX and did you download the happyfuntimes installer or did you clone this repo? I'm guessing you used the installer?

YinYin-Falcon commented 8 years ago

Just entering the ipv4 on the phone works.

I am on windows 8.1 and used the installer.

greggman commented 8 years ago

Ok, here's a zip file with a new version. Could you try it?
HappyFunTimes-0.0.47-installer.exe.zip

If it doesn't work, with happyfuntimes running, please go to http://docs.happyfuntimes.net/debug-hft-net.html on your PC and post the results. Crossing my fingers

YinYin-Falcon commented 8 years ago

Not working yet and I can't seem to do or copy anything inside the console, so here's a screencap of what happened (it opened a happyfuntimes tab in chrome on the Running line): http://i.imgur.com/lZAlnhw.png

Address still doesn't work, direct ipv4 address still works.

PC: { "gameIps": [ "192.168.0.2:18679" ], "publicIps": [ "95.90.234.0" ] } phone: { "gameIps": [], "publicIps": [ "2a02:8109:8380:116c:c1c0:5aaf:43d2:483a", "66.249.81.158" ] }

greggman commented 8 years ago

That screenshot was helpful. Can you stop and start happyfuntimes and try again?

YinYin-Falcon commented 8 years ago

Haha, those red tries went all the way to 62 out of 60 previously.

Address still doesn't work, direct ipv4 address still works. But no more connection troubles reported: http://i.imgur.com/JeImhiz.png PC:

{
  "gameIps": [
    "192.168.0.2:18679",
    "[2001:0:5ef5:79fd:205c:3d15:3f57:fffd]:18679",
    "[2a02:8109:8380:116c:4dba:3002:d6df:66db]:18679",
    "[2a02:8109:8380:116c:9994:c44f:7622:d0ec]:18679",
    "[2a02:8109:8380:116c::2]:18679",
    "[fd00:8494:8ce4:f2a2:4dba:3002:d6df:66db]:18679",
    "[fd00:8494:8ce4:f2a2:d002:d719:77cd:b8a4]:18679"
  ],
  "publicIps": [
    "95.90.234.0"
  ]
}

phone: { "gameIps": [], "publicIps": [ "2a02:8109:8380:116c:c1c0:5aaf:43d2:483a", "66.249.81.162" ] }

greggman commented 8 years ago

Sorry I'm asking you to try so much stuff. I don't have an ipv6 connection so there's no easy way to test that I know of. Can you try the following

First open a command prompt and type

nslookup -q=aaaa happyfuntimes.net

If it somewhere prints a number that starts with

2604:a880

Then, try going to http://docs.happyfuntimes.net/debug-hft-net.html on your PC again, maybe reboot it once. I'm in voodoo land here. I tried to make sure the happyfuntimes.net server is accessable from ipv6 and I updated happyfuntimes.net to have an ipv6 address. I'm wondering if that will help at all. Probably not because your phone already is providing an ipv6 public IP address. I'm just trying to figure out why you're PC is not (or why happyfuntimes.net is not seeing it)

YinYin-Falcon commented 8 years ago

Rebooted. It does:

Non-authoritative answer:
Name:    happyfuntimes.net
Address:  2604:a880:0:1010::1

http://i.imgur.com/7x4pxtc.png PC:

{
  "gameIps": [
    "192.168.0.2:18679",
    "[2001:0:5ef5:79fd:205c:3d15:3f57:fffd]:18679",
    "[2a02:8109:8380:116c:4dba:3002:d6df:66db]:18679",
    "[2a02:8109:8380:116c:9994:c44f:7622:d0ec]:18679",
    "[2a02:8109:8380:116c::2]:18679",
    "[fd00:8494:8ce4:f2a2:4dba:3002:d6df:66db]:18679",
    "[fd00:8494:8ce4:f2a2:d002:d719:77cd:b8a4]:18679",
    "[2001:0:9d38:90d7:141e:5fc4:a0a5:15ff]:18679",
    "[2a02:8109:8380:116c:802:9d4e:be64:8c2d]:18679",
    "[fd00:8494:8ce4:f2a2:802:9d4e:be64:8c2d]:18679"
  ],
  "publicIps": [
    "95.90.234.0"
  ]
}

phone: { "gameIps": [], "publicIps": [ "2a02:8109:8380:116c:9d4a:243c:5be5:27ab", "66.249.81.166" ] }

Don't see a change as expected. So the problem is that hft only gets the public v4 ip on the game machine and no v6 ip? Is there a difference in how the phone/client gets the publicIps values?

greggman commented 8 years ago

In the case of going to http://docs.happyfuntimes.net/debug-hft-net.html I don't really know. I would assume that info based on how your phone and PC's browser connects to happyfuntimes.net. I'm actually kind of surprised the phone shows 2 public ip addresses. Yes it has 2 but I'd think the server would only see one of them, whichever one it connected to the server with.

Any case the server is using node.js, when it gets request it just looks at some fields in the request object that tells public IP address. My thinking/hope was that both browsers would try IPv6 first if there was an ipv6 address for happyfuntimes.net but I have no idea how they pick which way to connect.

I'm setting up a remote linux box I can run happyfuntimes on that has ipv6. If I'm lucky it will have the same issues and I can debug. If not I'll have to see if I can setup a remote Windows box somewhere that has ipv6

greggman commented 8 years ago

Please try this one

HappyFunTimes-0.0.47-installer.exe.zip

yes, it has the same version number as before

YinYin-Falcon commented 8 years ago

It works! :D

greggman commented 8 years ago

Yay! 😀