org.apache.http.NoHttpResponseException Exception for some Marketo APIs

Anonymous
Not applicable

org.apache.http.NoHttpResponseException Exception for some Marketo APIs

Hi,

I am facing some issue while executing POST APIs of Marketo for the objects where we can specify multiple records in an individual call. I was trying to create more than 100 records(e.g. companies,leads) in two different threads. Each thread is having its own set of (company/lead) data.

When I am executing these two threads multiple times one after another then randomly one of the thread fails with below exception details:

Exception Class : org.apache.http.NoHttpResponseException Exception : org.apache.http.NoHttpResponseException: hostname:443 failed to respond

I have not observed such behavior for other POST APIs like Folder,File etc which accept single record for single call.

Please provide your inputs on - If this is an API issue or Are we missing something at our end.

3 REPLIES 3
Kenny_Elkington
Marketo Employee

Re: org.apache.http.NoHttpResponseException Exception for some Marketo APIs

Do you happen to have an example call that failed?

Anonymous
Not applicable

Re: org.apache.http.NoHttpResponseException Exception for some Marketo APIs

Hi

Below is the code snippet and APIs I was trying to hit.

URL: http://hostname:port/rest/v1/companies.json
Http request : POST
Input/Body : "{\"action\":\"createOrUpdate\", \"dedupeBy\":\"dedupeFields\",\"input\":[{\"externalCompanyId\":\"19UYA31791L000001\",\"company\":\"Google\"}]}"

Main Method:
public static void main(String[] args) {   
              test test = new test();
              for (int i = 0; i < 100; i++) {
                     Thread t1 = new Thread(test, "Thread-t1-" + i);
                     t1.start();
                     Thread t2 = new Thread(test, "Thread-t2-" + i);
                     t2.start();
                     Thread t3 = new Thread(test, "Thread-t3-" + i);
                     t3.start();
                     Thread t4 = new Thread(test, "Thread-t4-" + i);
                     t4.start();
                     Thread t5 = new Thread(test, "Thread-t5-" + i);
                     t5.start();
                     Thread t6 = new Thread(test, "Thread-t6-" + i);
                     t6.start();
                     Thread t7 = new Thread(test, "Thread-t7-" + i);
                     t7.start();
             }
       }

In run method of each thread I am hitting the API to create company as below:

@Override
       public void run() {
            System.out.println("Starting : " + Thread.currentThread().getName());
            try {
   String jsonContent = "{\"action\":\"createOrUpdate\", \"dedupeBy\":\"dedupeFields\","+
     "\"input\":[{\"externalCompanyId\":\"19UYA31791L000001\",\"company\":\"Google\"}]}";
   RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
   HttpPost httpPost = new HttpPost("/rest/v1/companies.json");
   httpPost.setHeader("Authorization", "Bearer <access-token>");
   httpPost.setHeader("Content-Type", "application/json");
   httpPost.setHeader("Accept", MarketoConstants.ACCEPT);
   httpPost.setConfig(config);
   httpPost.setEntity(new StringEntity(jsonContent));
   System.out.println("Executing request " + httpPost.getRequestLine() + " to " + endpoint);
   CloseableHttpResponse response = httpClient.execute(endpoint, httpPost);
   System.out.println(response.getStatusLine());
   System.out.println(EntityUtils.toString(response.getEntity()));
  } catch (Exception e) {
   System.out.println("Exception : " + Thread.currentThread().getName());
   e.printStackTrace();
  }
  System.out.println("Completing : " + Thread.currentThread().getName());
}

The response behavior is quite random.

Sometimes we get above exception or sometimes we got response as

HTTP/1.1 200 OK

{"requestId":"10f54#153cc2de3fb","success":false,"errors":[{"code":"606","message":"Max rate limit '100' exceeded with in '20' secs"}]}

Please provide your inputs on it.

Thanks!!

Kenny_Elkington
Marketo Employee

Re: org.apache.http.NoHttpResponseException Exception for some Marketo APIs

My guess would be your getting packets dropped at the load-balancer, your test is running through 700 update requests in basically however fast your machine can accomplish it.  If you added some throttling to a maximum of 15 concurrent requests, then I would expect you would stop seeing this.