# Bsearch API timeout (internal server error - 500)

**URL:** <https://discuss.elastic.co/t/bsearch-api-timeout-internal-server-error-500/361477>\
**Category:** Kibana\
**Created:** [June 14, 2024, 8:59am UTC](https://discuss.elastic.co/t/bsearch-api-timeout-internal-server-error-500/361477 "2024-06-14T08:59:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priyanka\_Narne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priyanka_narne/32/135299_2.png) [@Priyanka\_Narne](https://discuss.elastic.co/u/Priyanka_Narne)\
**Post date:** [June 14, 2024, 8:59am UTC](https://discuss.elastic.co/t/bsearch-api-timeout-internal-server-error-500/361477/1 "2024-06-14T08:59:56Z")

</div>

We are trying to implement Histogram for displaying data ingestion similar to Kibana Discover page using bsearch API.

Sometimes we are getting ID, but data is empty in the response. When we try to refetch the data without delay using the ID, we are getting an internal server error. But if we try with a delay of around 10 seconds, we are getting 200 status (sometimes id with empty data and sometimes only data).

Kibana is not facing this issue but when we are trying to use the API, we are facing this issue. Is there a way to handle this?

Response with id and no data:

 ![kibana_community](https://us1.discourse-cdn.com/elastic/original/3X/0/c/0cb29c2739aae176cea3609076f09d13043cc111.png)

Error:  
FetchError: request to http://\***/internal/bsearch?compress=false failed, reason: socket hang up  
at ClientRequest. (**\node\_modules\node-fetch\lib\index.js:1461:11)  
at ClientRequest.emit (node:events:518:28)  
at Socket.socketOnEnd (node:\_http\_client:519:9)  
at Socket.emit (node:events:530:35)  
at endReadableNT (node:internal/streams/readable:1696:12)  
at process.processTicksAndRejections (node:internal/process/task\_queues:82:21) {  
type: 'system',  
errno: 'ECONNRESET',  
code: 'ECONNRESET'  
}

---

<div class="post-metadata">

**Author:** ![Dzmitry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dzmitry/32/65026_2.png) [@Dzmitry](https://discuss.elastic.co/u/Dzmitry)\
**Post date:** [June 17, 2024, 2:11pm UTC](https://discuss.elastic.co/t/bsearch-api-timeout-internal-server-error-500/361477/2 "2024-06-17T14:11:32Z")

</div>

Hey @Priyanka_Narne

bsearch API is marked `internal` and not suppose to be used externally.

If you are trying to build something externally outside the Kibana, the better option is to use the [Elasticsearch Search API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html)  
You can find the ideas by looking into bsearch queries, but re-implementing Kibana internal logic might be tricky.

Best, Dima

---

<div class="post-metadata">

**Author:** ![Priyanka\_Narne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priyanka_narne/32/135299_2.png) [@Priyanka\_Narne](https://discuss.elastic.co/u/Priyanka_Narne)\
**Post date:** [July 9, 2024, 6:51am UTC](https://discuss.elastic.co/t/bsearch-api-timeout-internal-server-error-500/361477/3 "2024-07-09T06:51:35Z")

</div>

Thank you for the reply @Dzmitry
