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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
31 1 0 1

Simple API connection fails

Hi,

I have tried to run a simple API connection from python. I have read the forums and tried most of the things I could find.

After I enabled debug, the python error I get is this one:

2020-08-26 12:20:59,015 P[12560] [MainThread 20152] Timeout on checking port 9060
2020-08-26 12:20:59,015 P[12560] [MainThread 20152] Warning: file .portInUse was not found. Try to fallback to default port number.
2020-08-26 12:20:59,015 P[12560] [MainThread 20152] Try defaulting to port 9000...
2020-08-26 12:21:09,016 P[12560] [MainThread 20152] Timeout on checking port 9000
2020-08-26 12:21:09,016 P[12560] [MainThread 20152] Try defaulting to port 36036...
2020-08-26 12:21:19,017 P[12560] [MainThread 20152] Timeout on checking port 36036
2020-08-26 12:21:19,017 P[12560] [MainThread 20152] Error: no proxy address identified.
Check if Eikon Desktop or Eikon API Proxy is running.
2020-08-26 12:21:19,017 P[12560] [MainThread 20152] Port number was not identified, cannot send any request
2020-08-26 12:21:19,017 P[12560] [MainThread 20152] Init a Desktop session with new app_key
2020-08-26 12:21:19,017 P[12560] [MainThread 20152] Port number was not identified.
Check if Eikon Desktop or Eikon API Proxy is running.
Traceback (most recent call last):
  File "C:/personal projects/Eikon Database/Coding/get_sp500.py", line 9, in <module>
    ek.set_app_key("090264f7d76641bbb49b7110a6046a3f04f863d9")
  File "C:\personal projects\Eikon Database\Coding\venv\lib\site-packages\eikon\Profile.py", line 38, in set_app_key
    get_profile().set_app_key(app_key)
  File "C:\personal projects\Eikon Database\Coding\venv\lib\site-packages\eikon\Profile.py", line 233, in set_app_key
    self.check_profile()
  File "C:\personal projects\Eikon Database\Coding\venv\lib\site-packages\eikon\Profile.py", line 346, in check_profile
    raise EikonError(-1, 'Port number was not identified. Check if Eikon Desktop or Eikon API Proxy is running.')
eikon.eikonError.EikonError: Error code -1 | Port number was not identified. Check if Eikon Desktop or Eikon API Proxy is running.

Process finished with exit code 1


I have run the troubleshooting steps found on the forum:
I can connect to: http://localhost:9000/ping?all

{"port": 9000,"mode": "eikon4","pid": 9604,"hasSecure": true,"startedTime": "Wed Aug 26 2020 11:55:54 GMT+0200 (Romance Daylight Time)","subApps": [{"path": "/heap"},{"path": "/ping"},{"path": "/sxs","data": {"hasSecure": true,"sxsApps": {}}},{"path": "/api"},{"path": "/sxs/v1/services/messenger"}]} 

However I can not connect to: http://localhost:9060/api

{"code": 500,"message": "Cannot find module \".\"","statusMessage": "Internal Server Error"}  

The .portInUse file exists and has the value 9060. I debuged the desktop_session.py code and it finds it. The problem is that it can not establish the connectivity.

I am attaching the SxS file as instructed in other posts and also the result of running the powershell debug script.

powershell-result.txt

SxS.20200826.115544000.p9604.txt


eikon library version is 1.1.5
Refinitiv Desktop App version 4.0.52

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonport-number
icon clock
10 |1500

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

Upvotes
Accepted
39.2k 75 11 27

@ratiubogdan

We identified the root cause of the problem, which manifests with Python 3.8+. The root cause happened to be in the dependencies of Eikon Data APIs for Python library (requests-async, http3 and nest-asyncio).
The problem has been addressed in Eikon Data APIs for Python library v1.1.6, which is now available on PyPI. Would you be so kind as to upgrade eikon module on your machine to v1.1.6 and see if it works? I'd very much appreciate if you could post your experience back on this thread.
Thank you very much for your feedback.

icon clock
10 |1500

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

Hi Alex,
Yes, I have upgraded the eikon module to 1.1.6 and I was able to connect properly. No more errors.
Yes, I am using python 3.8 in my environment, so your solution seems to be correct.
Thanks for following up
Bogdan

Upvotes
39.2k 75 11 27

@ratiubogdan

Thank you for troubleshooting the issue and providing all these details. What I find very confusing is that the logger (which is written to in desktop_session.py) says that .portInUse file was not found. Yet you say that, when you debug desktop_session.py, the file is found. Could you shed any light on this discrepancy? How did you debug desktop_session.py and determined that .portInUse file was found?

icon clock
10 |1500

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

Upvotes
31 1 0 1

Hi Alex, thanks for the reply.
Here are the details. The function that checks the port is identify_scripting_proxy_port() inside desktop_session.py. Here is the function with my debug messages:


async def identify_scripting_proxy_port(self):
    """
    Returns the port used by the Scripting Proxy stored in a configuration file.
    """

    port = None
    path = []
    app_names = ["Data API Proxy", "Eikon API proxy", "Eikon Scripting Proxy"]
    for app_author in ["Refinitiv", "Thomson Reuters"]:
        if platform.system() == "Linux":
            path = path + [user_config_dir(app_name, app_author, roaming=True)
                    for app_name in app_names if os.path.isdir(user_config_dir(app_name, app_author, roaming=True))]
        else:
            path = path + [user_data_dir(app_name, app_author, roaming=True)
                    for app_name in app_names if os.path.isdir(user_data_dir(app_name, app_author, roaming=True))]

    if len(path):
        print(f"I found the path: {path}")
        port_in_use_file = os.path.join(path[0], ".portInUse")
        print(f"The port in use file {port_in_use_file}")

        # Test if ".portInUse" file exists
        if os.path.exists(port_in_use_file):
            print("The path and the file exists!")
            # First test to read .portInUse file
            firstline = self.read_firstline_in_file(port_in_use_file)
            if firstline != "":
                saved_port = firstline.strip()
                print(f"I read the following port {saved_port} from the file")
                await self.check_port(saved_port)
                if self._check_port_result:
                    port = saved_port
                    self.log(logging.INFO, f"Port {port} was retrieved from .portInUse file")

    if port is None:
        self.log(logging.INFO, "Warning: file .portInUse was not found. Try to fallback to default port number.")
        port_list = ["9000", "36036"]
        for port_number in port_list:
            self.log(logging.INFO, f"Try defaulting to port {port_number}...")
            await self.check_port(port_number)
            if self._check_port_result:
                return port_number

    if port is None:
        self.log(logging.ERROR,
                 "Error: no proxy address identified.\nCheck if Eikon Desktop or Eikon API Proxy is running.")
        return None

Please notice the added print() that I have added. Here is the run result:

I found the path: ['C:\\Users\\Ratman\\AppData\\Roaming\\Refinitiv\\Data API Proxy']
The port in use file C:\Users\Ratman\AppData\Roaming\Refinitiv\Data API Proxy\.portInUse
The path and the file exists!
I read the following port 9060 from the file
2020-08-26 21:38:21,748 P[7596] [MainThread 22424] Timeout on checking port 9060
2020-08-26 21:38:21,748 P[7596] [MainThread 22424] Warning: file .portInUse was not found. Try to fallback to default port number.
2020-08-26 21:38:21,748 P[7596] [MainThread 22424] Try defaulting to port 9000...
2020-08-26 21:38:31,750 P[7596] [MainThread 22424] Timeout on checking port 9000
2020-08-26 21:38:31,750 P[7596] [MainThread 22424] Try defaulting to port 36036...
2020-08-26 21:38:41,753 P[7596] [MainThread 22424] Timeout on checking port 36036
2020-08-26 21:38:41,753 P[7596] [MainThread 22424] Error: no proxy address identified.
Check if Eikon Desktop or Eikon API Proxy is running.

So as you can see the behavior is like this: first it finds the .portInUse file, reads the first line, gets port 9060 and checks it. Because the check fails, the port variable is still None and the message is: 2020-08-26 21:38:21,748 P[7596] [MainThread 22424] Warning: file .portInUse was not found. Try to fallback to default port number. Which is a bit misleading since the file and the port are correct, but check_port() failed.

Anyways, I am still very puzzled on what the problem could be. Is there a way to check my account if I have the API permissions correctly set up? I could not think of another problem.
I have tried on another PC, same result and I have restarted this PC several times, same result.

Thanks again,

Bogdan

icon clock
10 |1500

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

Upvotes
39.2k 75 11 27

Hi Bogdan,

Thank you for additional details. They cleared my confusion.

I'm afraid you chose to register on this portal with a personal rather than a corporate email address, which means we cannot identify you and cannot check your account. This said, the logs you included indicate that the Eikon account you use is entitled for Eikon Data APIs. I don't think entitlements are a problem here. From your debugging what appears to be happening is that the HTTP GET request to http://localhost:9060/api/v1/data (as well as to http://localhost:9000/api/v1/data) times out instead of returning a response. The expected response is same that you got in a browser from http://localhost:9060/api (i.e. it's a response with HTTP status 500). In your case, however, a timeout exception is raised instead. Could you try using the requests library and see if you get a response using the following call

requests.get('http://localhost:9060/api/v1/data', timeout=10.0)
icon clock
10 |1500

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

Upvotes
31 1 0 1

Hi Alex,
I have added the code that you suggested:

print(requests.get('http://localhost:9060/api/v1/data', timeout=10.0))

The response is:

<Response [500]>


I also run the system test program. I noticed these connection warnings.

Diagnostic Result
Local Time: 2020-08-27T12:31:19+02:00
Machine Id: D38AAFE7-F754-4A08-D728-5F79E0791D81
Home Site: EMEA

---------------------------------------
Prerequisites
---------------------------------------

Pass
[Description] Eikon 4 Ready:  Pass
[Recommendation] Your PC is ready for Thomson Reuters Eikon 4 upgrade

Pass
[Description] WMI Service: Available
[Recommendation] System test can perform check properly.

Pass
[Description] Operating System: Windows 10 Pro 64-bit
[Recommendation] Supported: Windows 7 (Home Premium, Professional, Enterprise, Ultimate), Windows 8 (Basic, Pro, Enterprise), Windows 8.1 (Basic, Pro, Enterprise), Windows 10 64-bit (Home, Pro, Enterprise, Enterprise LTSB) Eikon 4.0.32 onwards, Windows Server 2008 R2 (64-bit), Windows Server 2012 R2 (64-bit) and Windows Server 2016.

Pass
[Description] Service Pack: SP0
[Recommendation] Supported: Windows 7, Windows 7 SP1 + KB3033929, Windows 8, Windows 8.1, Windows 10 Eikon 4.0.32 onwards, Windows Server 2008 R2, Windows Server 2008 R2 SP1 + KB3033929, Windows Server 2012 R2 and Windows Server 2016.

Info
[Description] Microsoft Excel Version: Excel 365 (2016) 64-bit

Info
[Description] Microsoft PowerPoint Version: PowerPoint 365 (2016) 64-bit

Info
[Description] Microsoft Word Version: Word 365 (2016) 64-bit

Pass
[Description] Microsoft Office: Office 365 (2016) 64-bit Click-to-Run
[Recommendation] Recommended: Office 2013 64-bit, Office 365 64-bit, Office 2016 64-bit Eikon 4.0.33 onwards

Info
[Description] Operating System Language: English, United States (1033) 

Pass
[Description] Visual Basic for Applications Version: 7.1 (32-bit), 7.1 (64-bit for Office 365)
[Recommendation] Supported VBA versions are 6.4, 6.5, 7.0 (32-bit), and 7.1 (32-bit).

Pass
[Description] Visual Basic for Applications - Microsoft Excel compatible: Pass

Pass
[Description] MSI Version: 5.0.18362.900
[Recommendation] Required: MSI 5.0 or higher

Pass
[Description] MSXML 3.0 Version: 3.0 SP11 (8.110.18362.239)
[Recommendation] Required: MSXML 3.0 SP1 or higher

Pass
[Description] MSXML 6.0 Version: 6.0 SP3 (6.30.18362.836)
[Recommendation] Required: MSXML 6.0 or higher

Pass
[Description] Browser Version: Internet Explorer 11
[Recommendation] Recommended: Internet Explorer 11

Pass
[Description] Temporary Internet Files folder size: 330 MB
[Recommendation] Recommend: 250 MB.

Info
[Description] Internet Availability Test: Internet is not accessible.

Pass
[Description] Delete Browsing History on Exit: Disabled
[Recommendation] Internet Explorer setting: Delete Browsing History on Exit must be disabled.

Pass
[Description] Browser JavaScript: Enabled

Pass
[Description] HTTP 1.1: Enabled

Pass
[Description] HTTPS Connection Check: Successful

Pass
[Description] HTTP 1.1 Through Proxy Connections: Enabled

Pass
[Description] Saving Encrypted Pages to Disk: SSL pages are cached. (User Preference)

Pass
[Description] Legacy Thomson Reuters Products: None detected.

Pass
[Description] .NET Framework Version: 2.0 SP2, 3.0 SP2, 3.5 SP1, 4.6.2
[Recommendation] Minimum: .NET 4.0 Client Profile.

Recommended: For optimal performance, update to 4.5.2 or higher as Microsoft has ended support for lower versions. See Microsoft’s notification.

Info
[Description] CPU Type: Intel64 Family 6 Model 94 Stepping 3

Info
[Description] CPU Vendor: GenuineIntel

Info
[Description] CPU Description: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz

Info
[Description] CPU Speed: 2.6 GHz
[Recommendation] Recommended CPU Speed is 2.4 GHz

Pass
[Description] Installed Memory: 16 GB (15.8 GB usable)
[Recommendation] Required: 4 GB Physical Memory (Minimum) , 8 GB (Recommended) , 12 GB (Preferred)

Pass
[Description] Screen Resolution: 1920 x 1080
[Recommendation] Minimum supported: 1024 x 768

Pass
[Description] Color Depth: 32-bit
[Recommendation] Minimum color depth: 32-bit

Pass
[Description] Free Disk Space: Drive C: has 131.26 GB of free space.
[Recommendation] Required free disk space is 900 MB. (Recommended: 1.60 GB)

---------------------------------------
Network
---------------------------------------

Warning
[Description] Download bandwidth for EMEA1 Private Network: 0 bps

Warning
[Description] Upload bandwidth for EMEA1 Private Network: 0 bps

Warning
[Description] Average Latency (One Way) for EMEA1 Private Network: 0 ms

Warning
[Description] Download bandwidth for EMEA1 Internet: 0 bps

Warning
[Description] Upload bandwidth for EMEA1 Internet: 0 bps

Warning
[Description] Average Latency (One Way) for EMEA1 Internet: 0 ms

It seems that none of these pages are available:
https://emea1.help.cp.extranet.thomsonreuters.biz/Apps/HelpDeployment/#cshid=104
https://emea1.help.cp.extranet.thomsonreuters.biz/Apps/HelpDeployment/#cshid=106
Not sure if this is an issue or not.

Please let me know what other debug information you need.

Best,
Bogdan

icon clock
10 |1500

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

Upvotes
31 1 0 1

Hi Alex,

I figured it out!

Since we established that the API server is working properly and returning the 500 code to requests that do not include the APP key, it means that there could be something wrong to the request the python library is sending.
Since the latest version was released in Aug 20 and a lot of people do not have my problem, maybe this latest version is the issue.
I have downgraded the eikon python library to 1.1.2 and it works perfectly! 1.1.4 launched on Aug 18 still has the same error.

This strongly suggests that 1.1.5 and 1.1.4 might have some bugs.

Best,
Bogdan

icon clock
10 |1500

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

Click below to post an Idea Post Idea