Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:02:45+00:00 2026-06-07T07:02:45+00:00

I have a desktop client that sends data to a web server and I

  • 0

I have a desktop client that sends data to a web server and I can’t seem to get through the proxy server.

Update: I am getting a 407 HTTP error when trying to communicate through the proxy.

When downloading information from my web server, everything is fine. Once the user configures the proxy server (using a dialog box I wrote) the download works fine. But uploading data using org.apache.http.client.HttpClient is not working.

I am configuring the proxy server with code like this after gathering the information from a JDialog.

        System.setProperty("http.proxyHost", proxyHost);
        System.setProperty("http.proxyPort", "" + portNumber);

Now, once we do that, simple downloads work fine. For instance, I have code that reads some xml data from my web server (see below). On the customer’s network the error in my catch block was displayed before the proxy settings were configured and then everything worked fine once the correct proxy was set.

/**
 * Loads a collection of exams from the web site. The URL is determined by
 * configuration or registration since it is State specific.
 */
public static int importExamsWS(StringBuilder msg) {
    try {
        java.net.URL onlineExams = new URL(examURL);
        //Parse the XML data from InputStream and store it.
        return importExams(onlineExams.openStream(), msg);

    } 
    catch (java.net.UnknownHostException noDNS) {
        showError(noDNS, "Unable to connect to proctinator.com to download the exam file.\n"
                + "There is probably a problem with your Internet proxy settings.");
    }
    catch (MalformedURLException | IOException duh) {
        showFileError(duh);
    }
    return 0;
}

However, when I try to SEND data to the web server it is as if the proxy settings are being ignored and an IOException gets thrown. Namely:

org.apache.http.conn.HttpHostConnectException: Connection to http://proctinator.com:8080 refused

Now I know that port 8080 is not blocked by the customer’s web filter because we tested the address in a web browser.

Here is my code for verifying the registration ID entered by the user:
Update: Now I am also setting the proxy in this method.

//Registered is just an enum with ACTIVE, INACTIVE, NOTFOUND, ERROR
public static Registered checkRegistration(int id) throws IOException {    
    httpclient = new DefaultHttpClient();
    Config pref = Config.getConfig(); //stores user-entered proxy settings.
    HttpHost proxy = new HttpHost(pref.getProxyServer(), pref.getProxyPort());
    httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    URIBuilder builder = new URIBuilder();
    String path = "/Proctorest/rsc/register/" + id;
    try {
        builder.setScheme("http").setHost(server).setPort(8080).setPath(path);
        URI uri = builder.build();
        System.out.println("Connecting to " + uri.toString());
        HttpGet httpget = new HttpGet(uri);
        HttpResponse response = httpclient.execute(httpget);
        System.out.println(response.getStatusLine().toString());
        if(response.getStatusLine().getStatusCode()==200) {
            String msg = EntityUtils.toString(response.getEntity());
            GUI.globalLog.log(Level.INFO, "Server response to checkRegistration(" + id + "): " + msg);
            return Registered.stringToRegistered(msg);
        }
        else {
            GUI.globalLog.log(Level.INFO, "Server response status code to checkRegistration: " + 
                    response.getStatusLine().getStatusCode());
            return Registered.ERROR;
        }
    }
    catch(java.net.URISyntaxException bad) {
        System.out.println("URI construction error: " + bad.toString());
        return Registered.ERROR;
    }
}

I’m almost positive that the problem is coming from the proxy server configuration, yet the docs for SystemDefaultHttpClient claim that it takes uses System properties for http.proxyHost and http.proxyPort . I know that the properties have been properly set, but I am still getting this authentication error. Viewing the logs generated from my program showed me this:

checkRegistration INFO: Server response status code to checkRegistration: 407 

How do I resolve this authentication error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:02:47+00:00Added an answer on June 7, 2026 at 7:02 am

    I’ll take a shot. If the proxy server is using basic authentication, you could use the following snippet as an example:

    DefaultHttpClient httpclient = new DefaultHttpClient();
    httpclient.getCredentialsProvider().setCredentials(
        new AuthScope("PROXY HOST", 8080),
        new UsernamePasswordCredentials("username", "password"));
    
    HttpHost targetHost = new HttpHost("TARGET HOST", 443, "https");
    HttpHost proxy = new HttpHost("PROXY HOST", 8080);
    
    httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); 
    

    If the proxy server is using NTLM authentication, I do not believe NTLM support is available for all proxy server versions (it will work with some NTLM authentication proxy server versions – check if the proxy is using v1 or v2 of NTLM authentication). For reference & workarounds, you can check the following:

    http://hc.apache.org/httpcomponents-client-ga/ntlm.html

    http://htmlunit.sourceforge.net/ntlm.html

    http://devsac.blogspot.com/2010/10/supoprt-for-ntlmv2-with-apache.html

    Depending on your proxy server, you may need to look into NTCredentials instead of UserPasswordCredentials.

    I would also suggest that you may wish to look into using wireshark to capture network packets and check the response from the proxy server to be absolutely sure what is causing the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a desktop webapi server that I want to expose to clients through
I currently have a Firebird server on Windows and Windows desktop client applications for
I have a DESKTOP application which interacts with a web service through their RESTful
Coming from a desktop client background, with no real data-driven web design experience, I
I'm writing a Java desktop client application that retrieves data from a remote MySQL
Here's my use case. I have a desktop app that can download from my
I have an application that places several Windows within a com.extjs.gxt.desktop.client.Desktop. I need to
I have created a Virtual Desktop Manager for a client that allows him to
I have a payment processing client that runs exclusively on the desktop. The operator
i have using WCF service in my code that the client(WindowsFormsApplication1) capturing desktop view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.