Repository: searxng/searxng

Issue:
Bug: microsoft academic engine
**Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**
Repository: https://github.com/tiekoetter/searxng
Branch: master
Version: 1.0.0-972-93548243
<!-- Check if these values are correct -->

**How did you install SearXNG?**
<!-- Did you install SearXNG using the official wiki or using searxng-docker
or manually by executing the searx/webapp.py file? -->
**What happened?**
<!-- A clear and concise description of what the bug is. -->

**How To Reproduce**
<!-- How can we reproduce this issue? (as minimally and as precisely as possible) -->

**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->

**Screenshots & Logs**
<!-- If applicable, add screenshots, logs to help explain your problem. -->

**Additional context**
<!-- Add any other context about the problem here. -->

**Technical report**

Error
  * Error: httpx.TimeoutException
  * Percentage: 50
  * Parameters: `(None, None, None)`
  * File name: `searx/search/processors/online.py:97`
  * Function: `_send_http_request`
  * Code: `response = req(params['url'], **request_args)`




Discussion:
On my instance and searx.be, the microsoft academic engine doesn't have this timeout issue.

It seems to be specific to the searx.tiekoetter.com instance. The timeout of the engine should be higher 
https://github.com/searxng/searxng/blob/9fe1ee4ed964810c7de9a39ec7f865d0df96e5eb/searx/settings.yml#L872-L875

I suggest you to contact the searx.tiekoetter.com 's maintainer ( @tiekoetter on github). You can find the email at the bottom of the page ( Contact instance maintainer )

---

[EDIT] Looking at the engine tab on searx.space, the microsoft academic engine seems to timeout on a lot of instances, so the timeout can be increased on this repository.

AFAIK it depends on the search term .. some search terms have initial a timeout, when you repeat the same search term `!ma` response very fast.

[EDIT] lets increase the timeout from 3s to 6s
> some search terms have initial a timeout, when you repeat the same search term !ma response very fast.

On the first user request, there is no HTTPS connection between the instance and the MS server ; on the second request, the HTTPS connection always exists, so the response is faster time on second request and the first request may timeout.
My observation is different, it does not depend on the HTTPS connection .. it really depends on the search term.  Try different search terms and you might see what I mean .. 

EDIT: I retried and now my observation is again different ... may be you are right .. anyway, the only thing that helps is increasing the timeout

Resolving patch:
diff --git a/searx/engines/microsoft_academic.py b/searx/engines/microsoft_academic.py
--- a/searx/engines/microsoft_academic.py
+++ b/searx/engines/microsoft_academic.py
@@ -47,7 +47,7 @@ def response(resp):
     if not response_data:
         return results
 
-    for result in response_data['pr']:
+    for result in response_data.get('pr', {}):
         if 'dn' not in result['paper']:
             continue
 


Test patch: