> I did some investigation, the background downloader fails and exits because we try to connect to:
> We do a HttpSendRequest (DownloadHelper.cpp, function DownloadFile) on it, and it fails with error code:
> For some reason, it only fails with the initial background downloader instance. subsequent instance works fine.
> Also, I cannot reproduce the problem on my own xp machine. But it can always be reproduced on the east coast lab machine.
I tried with another xp lab machine in the west coast, and I cannot reproduce the problem on that machine either (both with or without proxy set).
This problem only occurs when jbroker is running as SYSTEM user, which is the default case when jbroker launches by the installer after installation. Also, the machine setup must requires proxy to connect to the internet.
That's why all the machines in SCA cannot reproduce, as all machines are directly connected to the internet now.
When the background downloader (running as SYSTEM) dies, HttpSendRequest fails and returns:
The server name could not be resolved.
But if we relaunch the process as Administrator (or any other admin user), it actually works.
With Ken's suggestion, we played around the argument to InternetOpen. Current code uses INTERNET_OPEN_TYPE_PRECONFIG, which will always get the proxy settings from registry automatically.
I changed it to use INTERNET_OPEN_TYPE_PROXY, and pass in the proxy server myself. And now it works!
So there might be a problem for InternetOpen to detect the proxy automatically when the process is associated to user "SYSTEM".
A possible fix for this bug is when we encounter 12007 from HttpSendRequest, we re-try the connection from the beginning, and call InternetOpen with INTERNET_OPEN_TYPE_PROXY and the proxy listed. We will need to add code to query registry directly for proxy settings.
Workaround for the problem for now is to kill the jbroker that is associated with SYSTEM, and then just do a "java -version" in the command prompt again to start both jbroker and the background downloader. This time it will work, as the user will now be administrator instead.