Lync/SfB Client tries to use proxy server instead of direct connection when using Proxy PAC on Windows 7

Update 2016/08/16 – This only happens on Windows 7, for Windows 8.1 and Windows 10 we don’t need to change the Proxy PAC file.

Recently we received some reports saying that Lync 2013 and Skype for Business 2015/2016 clients were trying to use a Proxy Server for lyncdiscover and lyncdiscoverinternal URLs when the Proxy was configured using a Proxy PAC script.

During the discovery process, the Lync/SfB client will check the Proxy PAC file with the following URLs:

http://lyncdiscoverinternal.gears.lab?sipuri=baird@gears.lab
https://lyncdiscoverinternal.gears.lab?sipuri=baird@gears.lab

http://lyncdiscover.gears.lab?sipuri=baird@gears.lab
https://lyncdiscover.gears.lab?sipuri=baird@gears.lab

For reference, here is a copy of my Proxy PAC file:

function FindProxyForURL(url, host) {

 /* Proxy all other hosts in gears.lab domain */
 if ((shExpMatch(host, "*.gears.lab"))) { return "DIRECT";}

 else { return "PROXY proxy.comm.lab:8080";}

}

We would expect that the following condition would cover the discovery URLs:

shExpMatch(host, “*.gears.lab”)

But it doesn’t, because the host variable will be:

lyncdiscover.gears.lab?sipuri=baird@gears.lab

Although the previous URL is valid it will cause issues in Windows 7.

We currently have two known workarounds:

1) Using the URL

This will match all the discovery URLs:

if ((shExpMatch(url, “http*://lyncdiscover*.gears.lab*”))) { return “DIRECT”;}

2) Using URL and Substring

This workaround requires that you check the length of each URL, but still it is also a valid alternative:

if (url.substring(0,29) == “http://lyncdiscover.gears.lab”) {return “DIRECT”;}
if (url.substring(0,30) == “https://lyncdiscover.gears.lab”) {return “DIRECT”;}
if (url.substring(0,37) == “http://lyncdiscoverinternal.gears.lab”) {return “DIRECT”;}
if (url.substring(0,38) == “https://lyncdiscoverinternal.gears.lab”) {return “DIRECT”;}