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

  • SEARCH
  • Home
  • 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 8187657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:38:10+00:00 2026-06-07T02:38:10+00:00

I am getting some problems after trying to convert my android app to use

  • 0

I am getting some problems after trying to convert my android app to use SSL to transport information between my android app and web server. (SocketTimeOutException)

I have bought a Positive SSL certificate from a Certificate Authority (CA) and configured my server to work with it correctly. I have tested it in my web browser and its working correctly.

Now I am trying to modify my android app to use https instead of http but as this is the first time I have used https myself, I am a little confused as to what steps I need to implement in the java code.

Currently I am working on my settings page where I configure my app to use the correct url. For example I have 2 text fields on an activity where I enter the website url (http://www.mydomain.com) and the application folder that the relevant pages are stored in (myappfolder)

I then use the following code to connect and test that the connection variables are configured correctly where validateurl.aspx is a webpage that returns a JSON string if the page exists:

protected boolean validateConnectionSettings() {        

    String result = "";
    boolean validated = false;
    try {
        StringBuilder urlBuilder = new StringBuilder();
        urlBuilder.append(tvWebsiteURLValue.getText() + File.separator + tvApplicationMiddlewareValue.getText() + File.separator + "validateurl.aspx");
        URL url = new URL(urlBuilder.toString());
        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); 
        url = uri.toURL();

        URLConnection urlConn = url.openConnection();
        BufferedReader in = new BufferedReader( new InputStreamReader(urlConn.getInputStream()));

        String inputLine;
        while((inputLine = in.readLine()) != null){
            result += inputLine;
        }                   
        in.close();

        if(result.equals("exists")) {
            validated = true;
        }

    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
        Log.e(TAG, e.getMessage());
    } catch (Exception e) {
        e.printStackTrace();
        Log.e(TAG, e.getMessage());
    }

    return validated;
}

Now when I try converting the (http://www.mydomain.com) variable to use https I get the above mentioned java.net.SocketTimeoutException.

I have googled this issue and seen that I should be implementing HttpsURLConnection instead of URLConnection in the above code so I have modified my code accordingly to the following:

    protected boolean validateConnectionSettings() {        

    String result = "";
    boolean validated = false;
    try {
        StringBuilder urlBuilder = new StringBuilder();
        urlBuilder.append(tvWebsiteURLValue.getText() + File.separator + tvApplicationMiddlewareValue.getText() + File.separator + "validateurl.aspx");
        URL url = new URL(urlBuilder.toString());
        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); 
        url = uri.toURL();

        // URLConnection urlConn = url.openConnection();
        HttpsURLConnection urlConn = (HttpsURLConnection)url.openConnection();
        BufferedReader in = new BufferedReader( new InputStreamReader(urlConn.getInputStream()));

        String inputLine;
        while((inputLine = in.readLine()) != null){
            result += inputLine;
        }                   
        in.close();

        if(result.equals("exists")) {
            validated = true;
        }

    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
        Log.e(TAG, e.getMessage());
    } catch (Exception e) {
        e.printStackTrace();
        Log.e(TAG, e.getMessage());
    }

    return validated;
}

However I still recieve the java.net.SocketTimeoutException. Any Ideas what Im doing wrong?

  • 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-07T02:38:11+00:00Added an answer on June 7, 2026 at 2:38 am

    Ok i found the issue that was causing the SocketTimeOutException.

    It seems that the problem was that I am working from my home and the phone is using the same network that the server is located on. It cannot seem to get to the server using https when this is the case. I turned the phones wireless network off and connected using the phones 3G connnection and hey presto the app connected and validated my URL.

    I had similar problems with testing the https connection directly from the server and my work laptop in a web browser. In each case I fixed the issue by adding the http://www.mydomain.com address into the host file.

    I’m now going to look into editing my android phones host file to see if this will solve it as I dont want to use the phones G3 connection for testing as I expect ill get lots of charges…

    Ill post a comment below later to say how it goes

    I hope this helps anyone else that has similar problems

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

Sidebar

Related Questions

I am getting some problems while trying to use this regex: (public +function|private +function|function)
I'm having some problems with my WCF server and client connections. If I use
after some advice regarding a problem i am getting using a linux based piece
I'm getting some problems with vertical aligment. I want to put my <span>›</span> element
Currently i am having some problems with getting some data out of a DataTable
Im having some problems getting the Sticky Footer to work on my site. If
I have problems getting some of my views aligned in a relative layout that
I'm having some problems getting ncurses' getch() to block. Default operation seems to be
I am having some problems getting my JS/JQ to fire in HTML5 page. Basically
I am having some problems getting a larger application with many table relationships working

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.