Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to game via IPv6 not working #9

Open
70fu opened this issue Jun 28, 2017 · 24 comments
Open

Connecting to game via IPv6 not working #9

70fu opened this issue Jun 28, 2017 · 24 comments

Comments

@70fu
Copy link

70fu commented Jun 28, 2017

I'm running my game in installation mode on a dedicated WLAN. When connecting to the game with an apple device via the captive portal, Safari shows the name input, but reloads the page every second, it also creates no player.
It behaves the same when trying to connect with the same IPv6 address, used by the captive portal, with my android smart phone on Chrome.
The used address seems to be an IPv4-mapped IPv6 address: [0000:0000:0000:0000:0000:ffff:c0a8:0001].

When connecting with the IPv4 address directly or using any domain name, I can play the game normally.

Is there also a possibility to run a game in installation mode without the captive portal?

@greggman
Copy link
Owner

greggman commented Jun 28, 2017

Edit Assets/WebPlayerTemplates/HappyFunTimes/hft/captive-portal/game-login.html

and change it from this

   <div class="hft-center hft-fullsize">
       <h1>HappyFunTimes</h1>
      <a id="start" href="%(startUrl)s">Start</a>
   </div>

to

   <div class="hft-center hft-fullsize">
       <h1>HappyFunTimes</h1>
       <h1>Please open your browser and go to hft.com</h1>
   </div>

The issue is Apple recently changed their captive portal system so that it will not automatically go to Safari anymore. I've been hoping there will be a workaround or they'll change back but until then this the only thing I can think of.

Turning off captive portal support might be an option I could look into adding. Users would just connect to the wifi and you'd have to tell them yourself to go to some domain name.

@70fu
Copy link
Author

70fu commented Jun 28, 2017

Thanks for the quick answer!

I don't think that this is caused by the captive portal, since using the same address with my android phone results in the same behaviour.

But using the captive portal to show further instructions is certainly a good workaround.

@greggman
Copy link
Owner

greggman commented Jun 29, 2017 via email

@greggman
Copy link
Owner

looks like it might be fixed in iOS 11

https://forums.developer.apple.com/thread/75498

@greggman
Copy link
Owner

greggman commented Jun 29, 2017

Oh, I'm sorry, I didn't see this was an issue on Android. What specific phone? I have no way to test Android at the moment and normal Android (Google Nexus, Pixel) didn't use to have a captive portal detector. Some other non Google Android phones do have captive portal detectors but I can't work around those without actually having access to the phone.

@70fu
Copy link
Author

70fu commented Jun 29, 2017

My Android phone does not support captive portals either. I'm just typing in the IPv6 address, the captive portal on my ipad is redirecting me to.

So here is a table how using the IPv6 address behaves on my android phone and my Ipad with different browsers:

Bug = Controller page seems to load, but no player is created and it's reloaded about every two seconds automatically (which seems to be the same behaviour when the controller gets disconnected from the game)
Sony = Sony Xperia Z + Android 5.1.1
ipad = Ipad Air 2 + ios 10.2

X [0000:0000:0000:0000:0000:ffff:c0a8:0001] [0000:0000:0000:0000:0000:ffff:c0a8:0001]:18679
Safari on ipad bug cannot connect
Firefox on ipad cannot connect, tries to make a google search cannot connect, tries a google search
Chrome on ipad bug bug
Chrome on Sony bug works
Firefox on Sony bug works
Opera on Sony bug works

192.168.0.1 -> always works
192.168.0.1:18679 -> always works
anydomainname.com -> always works

@greggman
Copy link
Owner

thank you for all the data. do you have cookies off?

in any case if you connect your phones to your computer via USB you should be able to open safari on the computer on mac and debug safari on iOS or chrome on desktop and debug chrome on Android.

if you go to the javasscript console and set it so it does not clear the console on reload then you'll probably see and error messsge which will help find the bug

https://blog.idrsolutions.com/2015/02/remote-debugging-ios-safari-on-os-x-windows-and-linux/

https://developers.google.com/web/tools/chrome-devtools/remote-debugging/

@70fu
Copy link
Author

70fu commented Jun 29, 2017

I've used Chrome Remote Debugging on my Android phone to get the console log when connecting using [0000:0000:0000:0000:0000:ffff:c0a8:0001]:

chromeremotedebuglog

@70fu
Copy link
Author

70fu commented Jun 29, 2017

And I haven't changed any settings regarding cookie, so I guess they are enabled on each device.

@greggman
Copy link
Owner

greggman commented Jun 29, 2017

You're on window or mac?

A few more things to try

One you could try this DLL. Unzip and put the dll it in Assets/Plugins

websocket-sharp.dll.zip

Another is, if you're on Windows you can turn on logging (if you're on mac there's more steps to debug the server)

In Unity please pick "Window->HappyFunTimes->Settings"

Then in the "Debug" area type * (note: the image below shows HTFSite but put * instead.

screen shot 2016-12-14 at 12 52 57 pm

Then run the game, all the output should be in the editor's log file. Drag and drop that log file into your reply below.

One more thing, can you turn off ipv6 on your router? Of course I'd like to make it work but since you're using installation mode then it doesn't really need ipv6 does it? that might solve it

@greggman
Copy link
Owner

Any luck?

@70fu
Copy link
Author

70fu commented Jun 30, 2017

Sorry, I did not have the time to do it sooner.

I've tried your dll, but without luck, it shows the exact same error when using chrome remote debug.

Here's the editor log file with all the logging information (also using the new dll), the log from the game starts at line 1071: Editor.log.zip

@greggman
Copy link
Owner

greggman commented Jun 30, 2017

How about this.

In Assets/HappyFunTimes/HappyFunTimesCore/HFTManager.cs

change around line 275 from this (set ipv6Address to null)

            string ipv4Address = String.IsNullOrEmpty(m_options.ipv4DnsAddress) ? HFTIpUtils.GetLocalIPv4Address() : m_options.ipv4DnsAddress;
            string ipv6Address = String.IsNullOrEmpty(m_options.ipv6DnsAddress) ? HFTIpUtils.GetLocalIPv6Address() : m_options.ipv6DnsAddress;

to this

            string ipv4Address = String.IsNullOrEmpty(m_options.ipv4DnsAddress) ? HFTIpUtils.GetLocalIPv4Address() : m_options.ipv4DnsAddress;
            string ipv6Address = null;

I'm not sure if that will fix it or not. You're running in installation mode so there's really no need for ipv6. So, this change should make the DNS part not return an address for IPV6 which makes me hope that both phones will just always go to ipv4

Let me confirm what you're trying to do.

  • You're running in installation mode
  • You have a router configured just for your installation
  • You want iOS and Android to be able to connect to the network and type some name in like hft.com and connect to the game

ipv6 does not need to work for that so I'm hoping the change above would fix it for you

@70fu
Copy link
Author

70fu commented Jul 1, 2017 via email

@greggman
Copy link
Owner

greggman commented Jul 1, 2017

If changing the code as above works for you I'll consider making installation mode ipv4 only by default so others don't run into this issue. (and also try it figure out why websockets isn't working on ipv6 in this case. I'm pretty sure it works over ipv6 otherwise).

Looking at the log it looks like you're running on Linux? Just checking so I can verify if the issue is only there or if it also exists on Windows and Mac

@70fu
Copy link
Author

70fu commented Jul 1, 2017

I'll try the code change with the original captive portal page to see where it's redirecting me to.

Indeed, I'm using Ubuntu Mate 16.04.

Maybe someone else should confirm this bug before making changes to the code, since it could be entirely my fault, but I don't know, that's why I've posted this issue.

@70fu
Copy link
Author

70fu commented Jul 1, 2017

After applying the code change, I'm still redirected to the same IPv6 address.

@greggman
Copy link
Owner

greggman commented Jul 1, 2017

Sorry I need more info. By "redirected" you mean you connected to the wifi on your phone and then typed in some domain name? Can you try a different domain name? (maybe the old domain name is cached)

Or did you mean on iOS the captive portal page popped up, you picked "start" and it redirected you?

I can go comment out all the IPV6 code but if DNS isn't serving an IPV6 address then there's no IPV6 address to redirect to AFAIK when typing in a domain name. Even the captive portal would only go to an IPV4 address I'm pretty sure.

You can try this too. Change Assets/HappyFunTimes/HappyFunTimesCore/HFTManager.cs from line 252 from this

            List<string> addresses = new List<string>();
            addresses.Add("http://[::0]:" + m_options.serverPort);
            #if UNITY_STANDALONE_WIN
            addresses.Add("http://0.0.0.0:" + m_options.serverPort);
            #endif

            if (m_options.installationMode)
            {
                addresses.Add("http://[::0]:80");
                #if UNITY_STANDALONE_WIN
                addresses.Add("http://0.0.0.0:80");
                #endif
            }

to this

            List<string> addresses = new List<string>();
            addresses.Add("http://0.0.0.0:" + m_options.serverPort);

            if (m_options.installationMode)
            {
                addresses.Add("http://0.0.0.0:80");
            }

Sorry this is so much work. I don't have a linux system I can test on and I think (though could be wrong) I can't get IPV6 running in a VM at the moment.

@70fu
Copy link
Author

70fu commented Jul 2, 2017

I was talking about the captive portal page, this is the only issue, since it tries to connect via ipv6 when pressing the start button.

DNS works fine on any phone and browser.

@greggman
Copy link
Owner

greggman commented Jul 3, 2017

I'm confused.

Android doesn't use the captive portal redirector so you have to manually type a domain name which you said works for you

iOS, with the change above, also requires you to manually type a domain name.

So if on both system you have to manually type a name and manually typing a name is working what's left?

I can try to fix the captive portal page without the change above but that won't help because current iOS 10 doesn't open the page in Safari when you click "Start". It just stays in the captive portal detector UI which can't run happyfuntimes.

@70fu
Copy link
Author

70fu commented Jul 3, 2017

Right, with the change above, the captive portal has no start button thus the player won't connect to the game via IPv6. The player won't run into an issue.

I'm sorry, that I did not say this clear enough before.

But I did not close this issue since the change above is just to prevent the user from connecting to the game via IPv6 (and from opening the controller page in the captive portal browser in ios10), but the IPv6 issue still exists.

@70fu
Copy link
Author

70fu commented Jul 3, 2017

But maybe the issue can be ignored, since it will be difficult to run into it when the change above is applied to the captive portal page.

@greggman
Copy link
Owner

greggman commented Jul 3, 2017

Well, if Apple fixes the captive portal stuff in iOS 11 then the problem will come back 😅

One question, does ipv6 work in normal non-installation mode? I know I've tested ipv6 on Windows and OSX in the past. I'll try to check it tonight to make sure it's still working and see if I can get Linux in a VM to use IPV6 too (not sure I can).

@greggman
Copy link
Owner

greggman commented Jul 5, 2017

So just fyi. I spent several hours trying to get ipv6 working on my router / pc, nothing to do with happyfuntimes, just trying to see some ipv6 addresses in ifconfig that make any kind of sense but so far no luck. I don't know what I'm doing wrong, my networking-fu is clearly not that good.

I have a Airport Extreme which should just work. My isp is ipv6 based but I must be missing some setting somewhere. I also have some OpenWRT router which I thought I could at least get ipv6 working for the lan side but no luck there either. I'll keep hacking

For the purpose of installation mode I'm leaning toward disabling ipv6 support if installation is on (and fixing the Start button redirect address).

Anyway, just giving a progress report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants