Closed starmessage closed 5 years ago
Possible workaround:
If the proxy does not require user credentials, then there is a netsh winhttp ...
command to redirect traffic to the proxy:
netsh winhttp set proxy proxy-server="http=192.168.1.126:808;https=192.168.1.126:808" bypass-list="*.whatever.com;localhost"
Other netsh winhttp ...
commands:
netsh winhttp show proxy
netsh winhttp reset proxy
netsh winhttp import proxy source =ie
If the proxy requires user credentials, then there is another idea from https://stackoverflow.com/questions/26992886/set-proxy-through-windows-command-line-including-login-parameters
The best way around this is (and many other situations) in my experience, is to use cntlm which is a local no-authentication proxy which points to a remote authentication proxy. You can then just set WinHTTP to point to your local CNTLM (usually localhost:3128), and you can set CNTLM itself to point to the remote authentication proxy. CNTLM has a "magic NTLM dialect detection" option which generates password hashes to be put into the CNTLM configuration files.
Version 0.9.3 of SoftMeter added a new function that sets the proxy server.
// If your software runs behind a proxy server (e.g. you are on a corporate network)
// set the proxy server details before calling any of the start() function.
// Currently, this function is in "alpha" version and works for Windows only.
// Values for authScheme under Windows:
// 0 = no authentication, 2 = NTLM, 4 = Passport, 8 = Digest, 16 = Negotiate
// If the proxy does not need authentication, use authScheme = 0 and the
// username and password will be ignored.
void setProxy(const smChar_t *address, const int port,
const smChar_t *username , const smChar_t *password, const int authScheme);
This is currently implemented only for the Windows OS. You can get the v0.9.3 DLLs from the usual "bin" folder.
``
If you are still having connection problems, do the following test:
Using an elevated (admin) command prompt, call netsh to import the WinINET (Internet Explorer) proxy settings:
netsh winhttp import proxy ie
For older Windows versions (XP and earlier) run proxycfg.exe to import WinINET's proxy settings:
proxycfg -u
On Windows Vista, Windows Server 2008, Windows 7, and Windows Server 2008 R2, the netsh command is specific to the bitness (32bit or 64bit) of the calling environment, so you may need to run the above command twice: first using the 32bit NetSh and then using the 64bit NetSh. The 64-bit netsh is run by default. To run the 32-bit netsh, change the current directory to Windows\SysWOW64 directory and run netsh there.
This limitation was fixed in Windows 8; you can call either NetSh just once to set the proxy for both 32bit and 64bit WinHTTP apps.
Then, print the proxy settings with netsh winhttp show proxy
When running behind a proxy, SoftMeter autodetects the presence of the proxy server and passes through it. But in some networks with a corporate proxy, the internet connection might not be detected correctly.
To test the connectivity of Softmeter behind a proxy or a firewall: Download from GitHub and save on a temp folder
Run:
cpp-demo-win <YOUR_PROPERTY_ID>
and the log file will open at the end of the run. If you are testing with your own app, you can find the log file by going to the temp directory. Start -> Run -> %temp%Look in the log file for error messages or for lines like:
Info> | httpPost() aborted because internet connection is down.
If you are on a 64bit Windows system, repeat the test also with the 64bit pair of files:
Send the log file to us by email.