# Using API Uncaught Server encountered exception

**URL:** <https://integration.keap.com/t/using-api-uncaught-server-encountered-exception/67745>\
**Category:** API Q&A\
**Tags:** api, php\
**Created:** [April 22, 2019, 7:14pm UTC](https://integration.keap.com/t/using-api-uncaught-server-encountered-exception/67745 "2019-04-22T19:14:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pavan\_Peri](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pavan\_Peri](https://integration.keap.com/u/Pavan_Peri)\
**Post date:** [April 22, 2019, 7:14pm UTC](https://integration.keap.com/t/using-api-uncaught-server-encountered-exception/67745/1 "2019-04-22T19:14:44Z")

</div>

Hello there,

All of sudden I am getting this error,

Uncaught Server encountered exception: Maximum number of threads throttled

PHP Fatal error: Uncaught Server encountered exception: Maximum number of threads throttled  
Attempted: 1 time(s).

The interesting thing is it works occasionally.

Please find the code below which is from PHP SDK  
do {  
if ($attempts \> 0){  
if (class\_exists(‘CakeLog’) && $attempts \> 1){  
$lastAttemptFaultCode = $req-\>faultCode();  
$lastAttemptFaultString = $req-\>faultString();  
}  
sleep(5);  
}  
$attempts++;  
$req = $this-\>client-\>send($call, $this-\>timeout, ‘https’);  
} while($retry && ($req-\>faultCode() == $GLOBALS[‘xmlrpcerr’][‘invalid\_return’] || $req-\>faultCode() == $GLOBALS[‘xmlrpcerr’][‘curl\_fail’] || strpos($req-\>faultString(), ‘com.infusionsoft.throttle.ThrottlingException: Maximum number of threads throttled’) !== false) && $attempts \< 3);

$this-\>totalHttpCalls += $attempts;  
if (!$req-\>faultCode()){  
$result = php\_xmlrpc\_decode($req-\>value());  
} else {  
$result = array();  
}

```
	if ($req->faultCode()){
		$exception = new Infusionsoft_Exception($req->faultString() .'Code'.$req->faultCode().' invalid_return '.$GLOBALS['xmlrpcerr']['invalid_return'].' curl_fail '.$GLOBALS['xmlrpcerr']['curl_fail']."\nAttempted: $attempts time(s).", $method, $args);
		$this->addException($exception);			
		throw $exception; 
		return FALSE;
	}

```

Any idea?

Thanks in advance.  
Rahul

---

<div class="post-metadata">

**Author:** ![John\_Borelli](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/john_borelli/32/11880_2.png) [@John\_Borelli](https://integration.keap.com/u/John_Borelli)\
**Post date:** [April 22, 2019, 10:37pm UTC](https://integration.keap.com/t/using-api-uncaught-server-encountered-exception/67745/2 "2019-04-22T22:37:19Z")

</div>

Hi, @Pavan_Peri,

That message should only come up under one of two conditions. Either exceeding the number of calls per second or exceeding the number of calls per day (see image from keys.infusionsoft…)

![image](https://us1.discourse-cdn.com/flex019/uploads/infusionsoft1/original/2X/5/51f87d35b144727e5b55ae235cb3335be0e1cae9.png)

---

<div class="post-metadata">

**Author:** ![Pavan\_Peri](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pavan\_Peri](https://integration.keap.com/u/Pavan_Peri)\
**Post date:** [April 23, 2019, 9:58am UTC](https://integration.keap.com/t/using-api-uncaught-server-encountered-exception/67745/3 "2019-04-23T09:58:36Z")

</div>

@John_Borelli  
Thank you for your reply here.  
Can you tell me where I can track that limits, please?

---

<div class="post-metadata">

**Author:** ![TomScott](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/tomscott/32/67_2.png) [@TomScott](https://integration.keap.com/u/TomScott)\
**Post date:** [April 26, 2019, 6:02pm UTC](https://integration.keap.com/t/using-api-uncaught-server-encountered-exception/67745/4 "2019-04-26T18:02:14Z")

</div>

There is a “View Reports” button on the key management page:  
[https://keys.developer.infusionsoft.com/apps/mykeys](https://keys.developer.infusionsoft.com/apps/mykeys)
