Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 1

Error code 408 \ HTTP TimeoutException

Recently, sometimes when I use eikon.get_data(), it will occur 408 error, and the error kept coming up for the next 30 mins. Then suddenly it can works well again to get the data I want. I want to know why and how can this problem be sovled.

The error show below:

2023-12-13 11:11:03,926 P[9384] [MainThread 8516] HTTP TimeoutException: .
Traceback (most recent call last):
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\anyio\_core\_tasks.py", line 115, in fail_after
yield cancel_scope
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\backends\asyncio.py", line 34, in read
return await self._stream.receive(max_bytes=max_bytes)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\anyio\_backends\_asyncio.py", line 1103, in receive
await self._protocol.read_event.wait()
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\asyncio\locks.py", line 214, in wait
await fut
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\asyncio\futures.py", line 285, in __await__
yield self # This tells Task to wait for completion.
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 304, in __wakeup
future.result()
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\asyncio\futures.py", line 196, in result
raise exc
asyncio.exceptions.CancelledError: Cancelled by cancel scope 2216762ac50


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\_exceptions.py", line 10, in map_exceptions
yield
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\backends\asyncio.py", line 32, in read
with anyio.fail_after(timeout):
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\anyio\_core\_tasks.py", line 118, in fail_after
raise TimeoutError
TimeoutError


The above exception was the direct cause of the following exception:


Traceback (most recent call last):
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_transports\default.py", line 60, in map_httpcore_exceptions
yield
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_transports\default.py", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\_async\connection_pool.py", line 261, in handle_async_request
raise exc
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\_async\connection_pool.py", line 245, in handle_async_request
response = await connection.handle_async_request(request)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\_async\connection.py", line 96, in handle_async_request
return await self._connection.handle_async_request(request)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\_async\http11.py", line 120, in handle_async_request
raise exc
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\_async\http11.py", line 99, in handle_async_request
) = await self._receive_response_headers(**kwargs)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\_async\http11.py", line 163, in _receive_response_headers
event = await self._receive_event(timeout=timeout)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\_async\http11.py", line 199, in _receive_event
data = await self._network_stream.read(
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\backends\asyncio.py", line 31, in read
with map_exceptions(exc_map):
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpcore\_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadTimeout


The above exception was the direct cause of the following exception:


Traceback (most recent call last):
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\eikon\json_requests.py", line 114, in send_json_request
response = profile.send_request(json=ticket_request, timeout=(15.0, 15.0))
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\eikon\Profile.py", line 348, in send_request
response = self._desktop_session.http_request(url=self.get_url(),
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\eikon\streaming_session\session.py", line 670, in http_request
response = loop.run_until_complete(self.http_request_async(url, method, headers, data,
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\nest_asyncio.py", line 99, in run_until_complete
return f.result()
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\asyncio\futures.py", line 201, in result
raise self._exception.with_traceback(self._exception_tb)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 232, in __step
result = coro.send(None)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\eikon\streaming_session\session.py", line 658, in http_request_async
raise t
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\eikon\streaming_session\session.py", line 637, in http_request_async
_request_response = await self._http_session.request(
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_client.py", line 1530, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_client.py", line 1617, in send
response = await self._send_handling_auth(
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_transports\default.py", line 352, in handle_async_request
with map_httpcore_exceptions():
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\httpx\_transports\default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadTimeout


During handling of the above exception, another exception occurred:


Traceback (most recent call last):
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\idlelib\run.py", line 578, in runcode
exec(code, self.locals)
File "D:\eikon\SCS.py", line 87, in <module>
data_root_1, err = ek.get_data("0#SGXIOS62:", fields_root ,field_name = True) # Iron Ore 62% Fe, CFR China(USD/MT)',
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\eikon\data_grid.py", line 190, in get_data
result = eikon.json_requests.send_json_request(_endpoint, payload, debug=debug)
File "C:\Users\JE Group Treasury\AppData\Local\Programs\Python\Python310\lib\site-packages\eikon\json_requests.py", line 131, in send_json_request
raise EikonError(408, error_msg)
eikon.eikonError.EikonError: Error code 408 | HTTP TimeoutException: .

#technologypython apierror-408
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@kathy.ky.ching

Hi,

Thank you for your participation in the forum.

Is the reply below satisfactory in answering your question?

If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

@kathy.ky.ching

Hi,

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

1 Answer

· Write an Answer
Upvotes
Accepted
4.9k 16 2 7

Hi @kathy.ky.ching


It is an HTTP request timeout. As much as I know timeout in the API is around 15 seconds. If Eikon doesn't respond to the ticket request within this timeout, it will throw this error.

                
  1. EikonError: Error code 408 | HTTP TimeoutException: .


you can try to change the timeout value by calling the following method.

                
  1. ek.set_timeout(50)

If it doesn't help, you may try to reduce the number of requested items or reduce the time range when requesting data.

I hope this will help.


Best regards,

Haykaz

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi, I already set the timeout value to 100 before, and sometimes I just ask for one RIC for CF_ASK data which has very just one row data, and still this error occurred. Could there be other reasons for this? Cause I set up automatic data extraction at 12 pm everyday. And this error often occurs which is very troublesome. Thank you

Hi @kathy.ky.ching ,


Another thing I can suggest is wrapping the API request in try except statement and retrying a couple of times. This may help avoid temporary sever overloads.

max_retries = 3
retries = 0
while retries<max_retries: 
    try:
        data_root_1, err = ek.get_data("0#SGXIOS62:", ['CF_NAME'], field_name = True) 
        break
    except Exception as e: 
        print(retries, e)
        retries +=1
        #time.sleep(5)
        continue
data_root_1 


Best regards,

Haykaz

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.