question

Upvotes
Accepted
16 1 1 2

Default proxy port #9000 failed

Timeout access Eikon API from Phyton


API status works from web browser (http://localhost:9000/ping?all and http://localhost:9060/api/status)


Running sample code returns timeout error.


Code:

import eikon as ek

ek.set_log_level(1)

ek.set_app_key('<app key here>')

df,e = ek.get_data('REUTERS','TR.RIC')


Output:

[2022-10-27 11:06:11,797;s] - [INFO] - [log] - Send GET request to http://127.0.0.1:9060/api/status to detect API Proxy...

[2022-10-27 11:06:11,805;s] - [DEBUG] - [log] - Request to http://127.0.0.1:9060/api/status

headers = {'x-tr-applicationid': '76a0963f007e46e3bf57b1ed35379e76e1e9c5df'}

params = None

[2022-10-27 11:06:26,955;s] - [Level 1] - [log] - TimeoutException on HTTP request: ReadTimeout('')

[2022-10-27 11:06:26,956;s] - [DEBUG] - [log] - Error on checking proxy url http://127.0.0.1:9060/api/status : ReadTimeout('')

[2022-10-27 11:06:26,957;s] - [INFO] - [log] - Retrieved port 9060 value from .portIntUse isn't valid.

[2022-10-27 11:06:26,958;s] - [INFO] - [log] - Warning: file .portInUse was not found. Try to fallback to default port number.

[2022-10-27 11:06:26,958;s] - [INFO] - [log] - Try defaulting to port 9000...

[2022-10-27 11:06:26,959;s] - [INFO] - [log] - Send GET request to http://127.0.0.1:9000/api/status to detect API Proxy...

[2022-10-27 11:06:26,959;s] - [DEBUG] - [log] - Request to http://127.0.0.1:9000/api/status

headers = {'x-tr-applicationid': '76a0963f007e46e3bf57b1ed35379e76e1e9c5df'}

params = None

[2022-10-27 11:06:41,995;s] - [Level 1] - [log] - TimeoutException on HTTP request: ReadTimeout('')

[2022-10-27 11:06:41,996;s] - [DEBUG] - [log] - Error on checking proxy url http://127.0.0.1:9000/api/status : ReadTimeout('')

[2022-10-27 11:06:41,997;s] - [DEBUG] - [log] - Default proxy port #9000 failed

[2022-10-27 11:06:41,997;s] - [INFO] - [log] - Try defaulting to port 9060...

[2022-10-27 11:06:41,998;s] - [INFO] - [log] - Send GET request to http://127.0.0.1:9060/api/status to detect API Proxy...

[2022-10-27 11:06:41,999;s] - [DEBUG] - [log] - Request to http://127.0.0.1:9060/api/status

headers = {'x-tr-applicationid': '76a0963f007e46e3bf57b1ed35379e76e1e9c5df'}

params = None

[2022-10-27 11:06:57,017;s] - [Level 1] - [log] - TimeoutException on HTTP request: ReadTimeout('')

[2022-10-27 11:06:57,017;s] - [DEBUG] - [log] - Error on checking proxy url http://127.0.0.1:9060/api/status : ReadTimeout('')

[2022-10-27 11:06:57,019;s] - [DEBUG] - [log] - Default proxy port #9060 failed

[2022-10-27 11:06:57,020;s] - [ERROR] - [log] - Error: no proxy address identified.

eikon-data-apieikon-com-apieikon-app-studio
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.

confirmed that Eikon is running and has realtime and portInUse is 9060

Upvotes
Accepted
80.2k 259 52 75

@kurt.dumangeng

Thank you so much for sharing your finding.

Eikon Data API supports a proxy setting via the Windows HTTP_PROXY variable. For example:

import os
os.environ['HTTP_PROXY']="http://127.0.0.1:8080"

It looks like it requires a proxy to connect to the localhost. I assumed that a web browser also uses a proxy to connect to http://localhost:9060/api/status.

You may verify a proxy setting used by a web browser. It may have a security application that blocks a connection to the localhost.


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.

Upvotes
14.4k 30 5 10

Hi @kurt.dumangeng ,

For further investigation, could you detail your

  • Eikon Desktop or Refinitiv Workspace application's version
  • Python version
  • Version of python libs below:
    • eikon
    • httpx
    • nest-asynco
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.

Upvotes
80.2k 259 52 75

@kurt.dumangeng

Sorry about the issue that you are facing.

Eikon Data API internally uses the httpx library to send HTTP requests so you need to check the version of those libraries mentioned by my colleague.

Moreover, you can try the following code to send an HTTP request to http://localhost:9060/api/status.

import httpx
session = httpx.AsyncClient(
            headers={"Accept": "application/json"},
            timeout=15,
        )
response = await session.request("GET","http://localhost:9060/api/status")
response.content

The output is:

1667360583561.png

I am using:

  • Eikon Data API 1.1.16
  • httpx 0.22.0
  • nest_asyncio 1.5.1

I hope that this information is of help


1667360583561.png (36.3 KiB)
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.

Upvotes
16 1 1 2

Hi Dev team,


My libraries:

Eikon 1.1.16

Httpx 0.22.0

Nest_asyncio 1.5.4

Please check if below code is ok. I was getting an “await outside async function” error and updated the code:

1667484816698.png

import httpx

import asyncio

session = httpx.AsyncClient(

headers={"Accept": "application/json"},

timeout=15,

)

async def request():

response = await session.request("GET", 'http://localhost:9060/api/status')

response.content

asyncio.run(request())

I get this error :

raise mapped_exc(message) from exc

httpx.ReadTimeout

It looks like there is definitely something blocking between python and eikon? As using chrome to access http://localhost:9060/api/status works fine.


1667484816698.png (16.8 KiB)
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.

Upvote
16 1 1 2

So I got it to work using this:

1667486042971.png

import requests

proxies = {

'http': 'http://localhost:9060',

}

r =requests.get('http://localhost:9060/api/status', timeout=30, proxies=proxies)

print(r.status_code)

print(r.text)

Output:

200

{"statusCode":"ST_PROXY_READY","version":"3.3.5-eikon4"}

Question: Is there a way to set the proxy within python using the Eikon library? Changing the Windows http_proxy variable works too, but I’d rather not use that solution.


1667486042971.png (11.9 KiB)
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.

Upvotes
16 1 1 2

Thank you so much! I have explained this to the IT and they will check it from their end. Thank you again


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.