question

Upvotes
Accepted
1 0 0 1

Connection Timeout and Eikon API never works for me

Eikon API keeps getting timed out always, changing the Timeout time by using ek.set_timeout(1000) does not change any anything, While the same code runs on my colleagues' computers irrespective of the app key.
The following are the steps I tried:

  1. Changing network time between Private and Internet
  2. Trying to fetch the data using a loop
  3. Running the script in codebook
  4. Upgrading the eikon application
  5. Reinstalling Eikon App

The code works when I try for very small time periods like 6 months and fails when I try over a year or two years

---------------------------------------------------------------------------
CancelledError                            Traceback (most recent call last)
/opt/conda/lib/python3.8/site-packages/httpcore/backends/asyncio.py in read(self, max_bytes, timeout)
     32                 try:
---> 33                     return await self._stream.receive(max_bytes=max_bytes)
     34                 except anyio.EndOfStream:  # pragma: nocover

/opt/conda/lib/python3.8/site-packages/anyio/_backends/_asyncio.py in receive(self, max_bytes)
   1202                 self._transport.resume_reading()
-> 1203                 await self._protocol.read_event.wait()
   1204                 self._transport.pause_reading()

/opt/conda/lib/python3.8/asyncio/locks.py in wait(self)
    308         try:
--> 309             await fut
    310             return True

/opt/conda/lib/python3.8/asyncio/futures.py in __await__(self)
    259             self._asyncio_future_blocking = True
--> 260             yield self  # This tells Task to wait for completion.
    261         if not self.done():

/opt/conda/lib/python3.8/asyncio/tasks.py in __wakeup(self, future)
    348         try:
--> 349             future.result()
    350         except BaseException as exc:

/opt/conda/lib/python3.8/asyncio/futures.py in result(self)
    172         if self._state == _CANCELLED:
--> 173             raise exceptions.CancelledError
    174         if self._state != _FINISHED:

CancelledError: 

During handling of the above exception, another exception occurred:

TimeoutError                              Traceback (most recent call last)
/opt/conda/lib/python3.8/site-packages/httpcore/_exceptions.py in map_exceptions(map)
      7     try:
----> 8         yield
      9     except Exception as exc:  # noqa: PIE786

/opt/conda/lib/python3.8/site-packages/httpcore/backends/asyncio.py in read(self, max_bytes, timeout)
     34                 except anyio.EndOfStream:  # pragma: nocover
---> 35                     return b""
     36 

/opt/conda/lib/python3.8/site-packages/anyio/_core/_tasks.py in __exit__(self, exc_type, exc_val, exc_tb)
    118         if self._cancel_scope.cancel_called:
--> 119             raise TimeoutError
    120 

TimeoutError: 

During handling of the above exception, another exception occurred:

ReadTimeout                               Traceback (most recent call last)
/opt/conda/lib/python3.8/site-packages/httpx/_transports/default.py in map_httpcore_exceptions()
     59     try:
---> 60         yield
     61     except Exception as exc:  # noqa: PIE-786

/opt/conda/lib/python3.8/site-packages/httpx/_transports/default.py in handle_async_request(self, request)
    352         with map_httpcore_exceptions():
--> 353             resp = await self._pool.handle_async_request(req)
    354 

/opt/conda/lib/python3.8/site-packages/httpcore/_async/connection_pool.py in handle_async_request(self, request)
    252                 await self.response_closed(status)
--> 253                 raise exc
    254             else:

/opt/conda/lib/python3.8/site-packages/httpcore/_async/connection_pool.py in handle_async_request(self, request)
    236             try:
--> 237                 response = await connection.handle_async_request(request)
    238             except ConnectionNotAvailable:

/opt/conda/lib/python3.8/site-packages/httpcore/_async/connection.py in handle_async_request(self, request)
     89 
---> 90         return await self._connection.handle_async_request(request)
     91 

/opt/conda/lib/python3.8/site-packages/httpcore/_async/http11.py in handle_async_request(self, request)
    104                 await self._response_closed()
--> 105             raise exc
    106 

/opt/conda/lib/python3.8/site-packages/httpcore/_async/http11.py in handle_async_request(self, request)
     83                     headers,
---> 84                 ) = await self._receive_response_headers(**kwargs)
     85                 trace.return_value = (

/opt/conda/lib/python3.8/site-packages/httpcore/_async/http11.py in _receive_response_headers(self, request)
    147         while True:
--> 148             event = await self._receive_event(timeout=timeout)
    149             if isinstance(event, h11.Response):

/opt/conda/lib/python3.8/site-packages/httpcore/_async/http11.py in _receive_event(self, timeout)
    176             if event is h11.NEED_DATA:
--> 177                 data = await self._network_stream.read(
    178                     self.READ_NUM_BYTES, timeout=timeout

/opt/conda/lib/python3.8/site-packages/httpcore/backends/asyncio.py in read(self, max_bytes, timeout)
     34                 except anyio.EndOfStream:  # pragma: nocover
---> 35                     return b""
     36 

/opt/conda/lib/python3.8/contextlib.py in __exit__(self, type, value, traceback)
    130             try:
--> 131                 self.gen.throw(type, value, traceback)
    132             except StopIteration as exc:

/opt/conda/lib/python3.8/site-packages/httpcore/_exceptions.py in map_exceptions(map)
     11             if isinstance(exc, from_exc):
---> 12                 raise to_exc(exc)
     13         raise  # pragma: nocover

ReadTimeout: 

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

ReadTimeout                               Traceback (most recent call last)
/opt/conda/lib/python3.8/site-packages/eikon/json_requests.py in send_json_request(entity, payload, debug)
    113                         logger.debug('Send ticket request:{}'.format(ticket_request))
--> 114                         response = profile.send_request(json=ticket_request, timeout=(15.0, 15.0))
    115 

/opt/conda/lib/python3.8/site-packages/eikon/Profile.py in send_request(self, json, timeout)
    347     def send_request(self, json, timeout=None):
--> 348         response = self._desktop_session.http_request(url=self.get_url(),
    349                                                       method="POST",

/opt/conda/lib/python3.8/site-packages/eikon/streaming_session/session.py in http_request(self, url, method, headers, data, params, json, auth, loop, **kwargs)
    669             loop = self._loop
--> 670         response = loop.run_until_complete(self.http_request_async(url, method, headers, data,
    671                                                                    params, json, auth, **kwargs))

/opt/conda/lib/python3.8/site-packages/nest_asyncio.py in run_until_complete(self, future)
     97                     'Event loop stopped before Future completed.')
---> 98             return f.result()
     99 

/opt/conda/lib/python3.8/asyncio/futures.py in result(self)
    177         if self._exception is not None:
--> 178             raise self._exception
    179         return self._result

/opt/conda/lib/python3.8/asyncio/tasks.py in __step(***failed resolving arguments***)
    279                 # don't have `__iter__` and `__next__` methods.
--> 280                 result = coro.send(None)
    281             else:

/opt/conda/lib/python3.8/site-packages/eikon/streaming_session/session.py in http_request_async(self, url, method, headers, data, params, json, closure, auth, loop, **kwargs)
    657             self.log(1, f'TimeoutException on HTTP request: {t!r}')
--> 658             raise t
    659         except Exception as e:

/opt/conda/lib/python3.8/site-packages/eikon/streaming_session/session.py in http_request_async(self, url, method, headers, data, params, json, closure, auth, loop, **kwargs)
    636         try:
--> 637             _request_response = await self._http_session.request(
    638                 method,

/opt/conda/lib/python3.8/site-packages/httpx/_client.py in request(self, method, url, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions)
   1526         )
-> 1527         return await self.send(request, auth=auth, follow_redirects=follow_redirects)
   1528 

/opt/conda/lib/python3.8/site-packages/httpx/_client.py in send(self, request, stream, auth, follow_redirects)
   1613 
-> 1614         response = await self._send_handling_auth(
   1615             request,

/opt/conda/lib/python3.8/site-packages/httpx/_client.py in _send_handling_auth(self, request, auth, follow_redirects, history)
   1641             while True:
-> 1642                 response = await self._send_handling_redirects(
   1643                     request,

/opt/conda/lib/python3.8/site-packages/httpx/_client.py in _send_handling_redirects(self, request, follow_redirects, history)
   1678 
-> 1679             response = await self._send_single_request(request)
   1680             try:

/opt/conda/lib/python3.8/site-packages/httpx/_client.py in _send_single_request(self, request)
   1715         with request_context(request=request):
-> 1716             response = await transport.handle_async_request(request)
   1717 

/opt/conda/lib/python3.8/site-packages/httpx/_transports/default.py in handle_async_request(self, request)
    352         with map_httpcore_exceptions():
--> 353             resp = await self._pool.handle_async_request(req)
    354 

/opt/conda/lib/python3.8/contextlib.py in __exit__(self, type, value, traceback)
    130             try:
--> 131                 self.gen.throw(type, value, traceback)
    132             except StopIteration as exc:

/opt/conda/lib/python3.8/site-packages/httpx/_transports/default.py in map_httpcore_exceptions()
     76         message = str(exc)
---> 77         raise mapped_exc(message) from exc
     78 

ReadTimeout: 

During handling of the above exception, another exception occurred:

EikonError                                Traceback (most recent call last)
/tmp/ipykernel_192/272308052.py in <module>
      1 start = time.time()
----> 2 epstest,err = ek.get_data(lister, fields, parameters = {'SDate':'2022-01-01','Frq':'W', 'EDate':"2024-09-09",  'curn':'USD'})
      3 end = time.time()
      4 print(end - start)

/opt/conda/lib/python3.8/site-packages/eikon/data_grid.py in get_data(instruments, fields, parameters, field_name, raw_output, debug)
    188         payload = {'requests': [payload]}
    189 
--> 190     result = eikon.json_requests.send_json_request(_endpoint, payload, debug=debug)
    191 
    192     if result.get('responses'):

/opt/conda/lib/python3.8/site-packages/eikon/json_requests.py in send_json_request(entity, payload, debug)
    129             error_msg = f'HTTP TimeoutException: {timeout_exception}.'
    130             logger.error(error_msg)
--> 131             raise EikonError(408, error_msg)
    132         except EikonError as eikon_err:
    133             logger.error(f"HTTP request failed: {type(eikon_err).__name__}-{eikon_err.message}")

EikonError: Error code 408 | HTTP TimeoutException: .

I have also read somewhere on the forum I can access the eikon api without having the app running through a proxy I believe. Can I get some information regarding that as well.


Thanks in Advance

eikon#technologytime-out
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.

1 Answer

· Write an Answer
Upvotes
Accepted
15.5k 33 5 10

Hi @kusumanchi.ashish ,

Regarding your question about connecting to the data platform without having Workspace/Eikon application up and running on the same machine, the LSEG Data Library for Python provide an ability to do so with Platform access point which requires RDP account to access it, more detail can be seen in its Quick start guide. Here's its example code in GitHub. It's timeout can be set on the Configuration file.

Hope this helps and please let me know in case you have any further questions.

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.

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.