[solved] juce::URL not connecting - what's wrong in this code snippet here?

I’m trying to communicate a licensekey authorization to my server.
Its not working, so I’m trying a test URL that should work - Google - and that is not connecting either.

I did see a topic here which talked about removing headers in Windows, and tried to respect that, but still not working.

I’m getting statusCode 0 which indicates a general networking error, but I can browse to my authentication https://mysite.com/trackauthentications.php page fine.

int statusCode = 0;
auto options = juce::URL::InputStreamOptions(juce::URL::ParameterHandling::inPostData)
    .withConnectionTimeoutMs(10000)
    .withStatusCode(&statusCode)

(I’m still on JUCE 7.0.9)

Is there something wrong here:

juce::URL testURL("https://www.google.com");
DBG("Testing connection with Google...");

auto testOptions = juce::URL::InputStreamOptions(juce::URL::ParameterHandling::inAddress)
            .withConnectionTimeoutMs(5000);

auto testStream = testURL.createInputStream(testOptions);
if (testStream == nullptr)
{
    DBG("Could not connect to Google.");
    return false;
}
else
{
    DBG("Successfully connected to Google.");
}

Don’t have any firewall or unorthodox proxy setup or anything - just standard.
image

Bump… has anyone got any ideas for me ? This has been an obstacle. I’ve tried a few things since my OP which don’t work.
Other plugins (almost certainly made by JUCE) in the past few years are authorizing fine. I’m sure its not a local firewall etc. issue.

examples tried:

        int statusCode = 0;
        auto options = juce::URL::InputStreamOptions(juce::URL::ParameterHandling::inPostData)
            .withConnectionTimeoutMs(10000)
            .withStatusCode(&statusCode)
            .withExtraHeaders("User-Agent: MyPlugin/1.0\r\n"
                "Accept: text/html\r\n"
                "Content-Type: application/x-www-form-urlencoded\r\n"
                "Expect:");

also:

.withExtraHeaders("User-Agent: mydaw/" 1.1 "\r\n"
                  "Accept: application/json\r\n"
                  "Content-Type: multipart/form-data\r\n")

And I’ve tried version with Headers removed.
status code is 0, not connecting

I haven’t done much with JUCE networking but there’s a networking Demo in JUCE’s DemoRunner you could look at and try to reproduce. You could also start a debugger on that line and go spelunking to see what’s going awry internally…

I looked at that demo. I’m getting a ‘failed to connect’ message there too.
I wonder if Windows updated something causing the failure?

You probably need to tell what request type you want to do. Try to start with minimal options and without the extra headers:

From my JUCE Koan File:

  • Always test http:// before you test https://

I’ll provide some final feedback here, since it might help someone else.

I had a local problem, even though other plugins from different vendors seemed to authorize fine.

Here’s what seemed to work:

  • I disabled my network adaptor for my rj45 hardwired network, and just kept the wifi adaptor going
  • In my Internet Options > LAN Settings, I didn’t have ‘automatically detect settings’ ticked on, even though there was no IP addresses inserted. Reboot.

Things that should have made an impact but seemed not to:

  • Removed SonicWall Netextender VPN (as it has hooks in the network settings)
  • Removed OracleVirtualBox as that also had hooks in the networking
  • Reset SChannel settings in the registry
  • netsh winsock reset

Seems like that list of 4 things would have made a deeper impact, but after I rebooted several time it still didn’t work. But those two at the top of the list seemed to make it work.

1 Like