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 8998183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:59:23+00:00 2026-06-15T23:59:23+00:00

I am trying to pass a command to my Arduino device using HTTP .

  • 0

I am trying to pass a command to my Arduino device using HTTP. The device receives the command, and it performs as expected. But I am getting an error in HttpClient.execute() as I mentioned below.. How do I correct the code?

protected String doInBackground(Void... params) {
    try {
        Log.i("CallArduino ","In doInBackground");
        final int TIMEOUT_MILLISEC = 1000;
        HttpParams httpParams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
        HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
        HttpClient client = new DefaultHttpClient(httpParams);
        //    URL="http://www.google.co.in";
        HttpGet get = new HttpGet(URL);

        Log.i("CallArduino ","before get");
                        responseGet = client.execute(get);
        Log.i("CallArduino ","after get");
        resEntityGet = responseGet.getEntity();

        Log.i("CallArduino ","in PostExecute");
        if (resEntityGet != null) {
            InputStream is = resEntityGet.getContent();
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);

            StringBuilder sb = new StringBuilder();
            sb.append(reader.readLine() + "\n");
            String line="0";
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            result=sb.toString();
        }
    }
    catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    finally{

    }

Output:

 12-08 12:58:10.419: I/CallArduino(5652): before get
 12-08 12:58:11.589: W/System.err(5652): java.net.SocketTimeoutException
 12-08 12:58:11.589: W/System.err(5652): at java.net.PlainSocketImpl.read(PlainSocketImpl.java:491)
 12-08 12:58:11.589: W/System.err(5652): at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
 12-08 12:58:11.589: W/System.err(5652): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
 12-08 12:58:11.599: W/System.err(5652): at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:103)
 12-08 12:58:11.599: W/System.err(5652): at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:191)
 12-08 12:58:11.599: W/System.err(5652): at org.apache.http.impl.io.AbstractMessageParser.parseHeaders(AbstractMessageParser.java:122)
 12-08 12:58:11.599: W/System.err(5652): at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:178)
 12-08 12:58:11.599: W/System.err(5652): at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:180)
 12-08 12:58:11.599: W/System.err(5652): at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235)
 12-08 12:58:11.599: W/System.err(5652): at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259)
 12-08 12:58:11.609: W/System.err(5652): at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
 12-08 12:58:11.609: W/System.err(5652): at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
 12-08 12:58:11.609: W/System.err(5652): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:428)
 12-08 12:58:11.609: W/System.err(5652): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:580)
 12-08 12:58:11.609: W/System.err(5652): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:512)
 12-08 12:58:11.609: W/System.err(5652): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:490)
 12-08 12:58:11.609: W/System.err(5652): at com.example.homeautomation.CallArduino$httpTask.doInBackground(CallArduino.java:87)
 12-08 12:58:11.609: W/System.err(5652): at com.example.homeautomation.CallArduino$httpTask.doInBackground(CallArduino.java:1)
 12-08 12:58:11.609: W/System.err(5652): at android.os.AsyncTask$2.call(AsyncTask.java:264)
 12-08 12:58:11.609: W/System.err(5652): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
 12-08 12:58:11.609: W/System.err(5652): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
 12-08 12:58:11.609: W/System.err(5652): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
 12-08 12:58:11.609: W/System.err(5652): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
 12-08 12:58:11.609: W/System.err(5652): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
 12-08 12:58:11.619: W/System.err(5652): at java.lang.Thread.run(Thread.java:856)
 12-08 12:58:11.619: I/CallArduino(5652): result  :null
  • 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-15T23:59:24+00:00Added an answer on June 15, 2026 at 11:59 pm

    It may be possible that your Internet Connection Speed is weak. You can increase your Timeout Interval by using following method.

    HttpConnectionParams.setSoTimeout(params, 1000);

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

Sidebar

Related Questions

I am trying to pass a string literal to a Popen command, but it
I am trying to pass property through command line parameter ($args[0]) as follows using
I am trying to pass bash user input read using the read command to
I am trying to execute a command using function calls in a shell script.
I am trying to pass arguments to execl() function for ls command. But when
I'm trying to pass command-line arguments to a C# application, but I have problem
I'm trying to pass external variable into awk using awk -v but just cannot
When trying to pass a CGPoint to a method the point is passed, but
I'm trying to pass UTF-8 text as an argument to a command line program
New to MVC, trying to pass a variable from Flash using FSCommand (works well

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.