3 Replies Latest reply on Apr 7, 2016 10:14 AM by Kenny Elkington

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



      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.

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


            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);
                                 Thread t2 = new Thread(test, "Thread-t2-" + i);
                                 Thread t3 = new Thread(test, "Thread-t3-" + i);
                                 Thread t4 = new Thread(test, "Thread-t4-" + i);
                                 Thread t5 = new Thread(test, "Thread-t5-" + i);
                                 Thread t6 = new Thread(test, "Thread-t6-" + i);
                                 Thread t7 = new Thread(test, "Thread-t7-" + i);

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

                   public void run() {
                        System.out.println("Starting : " + Thread.currentThread().getName());
                        try {
               String jsonContent = "{\"action\":\"createOrUpdate\", \"dedupeBy\":\"dedupeFields\","+
               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.setEntity(new StringEntity(jsonContent));
               System.out.println("Executing request " + httpPost.getRequestLine() + " to " + endpoint);
               CloseableHttpResponse response = httpClient.execute(endpoint, httpPost);
              } catch (Exception e) {
               System.out.println("Exception : " + Thread.currentThread().getName());
              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.