So I have a game that uses NetworkTransport and udp broadcasts to access other devices running the app.
I know that firewall blocks this as it works fine in editor where firewall has an exception, and it works fine when built to an .exe if I manually disable firewall, and doesn’t work if I don’t.
It isn’t very consumer friendly to ask them to disable the firewall or to go into settings and make an exception, so I want to know how to prompt the firewall pop-up that often appears in other online games, so that the user just have to click ok to a pop-up to allow connections for that specific program.
AFAIK the firewall prompt is something OS does automatically when it detects an application wants to host/listen on a specific port. I don’t think you can force it.
This depends on the firewall the user has. If a user has a firewall that only allow user whitelisted software as an example, there is no way to disable that without heavily going against the users will and even then it will be difficult. As for the operatingsystems os. I know windows have ways for you to ask them about firewall. You can even modify firewall settings from your application if ran with admin. And you could request admin while the application is being ran.
I don’t want to disable firewall, but rather have the typical pop-up that asks for white listing the game. I am primarily developing for windows, so if you have any more info on asking windows about firewall that would help a lot.
I don’t like the idea of modifying the firewall by gaining admin access though.
If you are talking about the Windows Defender Firewall that was introduced in XP. It will prompt users automatically. When you execute the exe it will automatically pop up a prompt, note that it only does this once. If the user press cancel, it will add a blacklist in the windows firewall. If you press allow it will add a whitelist. This firewall also has a nice API for you to use. https://msdn.microsoft.com/en-us/library/aa366458(VS.85).aspx
As for third party firewalls, you are probably better of not trying. They are often developed to be secure and don’t want programs modifying them. Personally I use a whitelist firewall on my linux machine which means I specifically have to whitelist applications I trust to allow them to make inbound and outbound connections. But windows protects these third party firewalls in a similar way they protect third party antivirus’s. They are not treated as usual programs but rather have special limitations.
I am talking about Windows Defender Firewall, at least for me to make it work I am whitelisting my build through Windows Firewall in Control Panel.
So my problem is exactly that I am not getting the behaviour that you mention on any of my machines: “It will prompt users automatically. When you execute the exe it will automatically pop up a prompt, note that it only does this once.”
I never got that pop-up, which is why i started this thread.
I am not worried about Linux users as they typically know what they are doing with computers. And I am not talking about any specialised Firewalls (at least I am pretty sure I am not).
Firewall is preventing my application from picking up other players, I thing it is the broadcast, but it might be the handshaking, but one of those two. When I build it doesn’t connect, unless I manually give the build permission in my firewall settings or disable firewall all together. It works fine in the editor, but only because the editor also has permission.
Anecdote if that randomly helps anything: When I updated from 2017.3.0 to 2017.3.1 the editor was blocked so I had to give it permission again.
I would be suprised if I cancelled it on my first build as I took me sometime to figure out what was wrong back then. I just send my build to a fresh PC to test it out there also, and nothing popped up.
I also tried building with a new name and even changed the product name in PlayerSettings in case that was the thing.
To clarify, I am not using any internet based connection, I am using broadcasting and NetworkTransport for local only.
Oh, that might be a difference then. Please check what the Firewall has to say about the application after on the new PC. Since it’s not doing any outbound network connections per say (even though it should use the network adapter?). Something might be going on. Check if the firewall treats it as blocked, allowed or neutral by default. I am unsure of this. But as I stated earlier. The Windows Defender Firewall has API’s you can use.
Still haven’t found a solution, outside of maybe hijacking the player’s firewall with the API. Since I am using NetworkTransport, maybe @aabramychev has an idea? Otherwise still open for input.
Yes and no. Still no solution from prompting with Unity. So what I ended up doing was enabling firewall through an installer for Windows. Kinda shitty way to do it, but less work for the player. I work on windows so I have no idea whether this issue exists on Mac and Linux to begin with.