Cannot connect anymore to DSWS through Python

Hello,

I've been using DSWS for a while on the same environment, but since last week I can no longer use it. Let me copy/paste what I get:


import DatastreamDSWS as DSWS


ds = DSWS.Datastream(username='...',password='...')

HTTPSConnectionPool(host='product.datastream.com', port=443): Read timed out. (read timeout=180)

_get_json_Response : Exception Occured:

HTTPSConnectionPool(host='product.datastream.com', port=443): Read timed out. (read timeout=180)


For your information here are some details on that environment:

Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)]

Type "copyright", "credits" or "license" for more information.


IPython 6.5.0 -- An enhanced Interactive Python.


Would you have any idea regarding this issue ?

Thanks.

Best Answer

  • Jirapongse
    Answer ✓

    @mathieu.duarte

    You can use the requests Python library to check network settings. Please try the following code in the same environment.

    import requests

    url = 'https://product.datastream.com/DSWSClient/V1/DSService.svc/rest/GetToken';
    myobj = {"Password": "<username>", 
             "Properties": [{"Key": "__AppId", "Value": "PythonLib-1.1.0"}], 
             "UserName": "<password>"}

    x = requests.post(url, json = myobj)
    print(x.status_code)
    print(x.text)

    You may need to enable HTTP logging in Python.

    import logging
    import http.client
     
    http.client.HTTPConnection.debuglevel = 1
     
    logging.basicConfig()
    logging.getLogger().setLevel(logging.DEBUG)
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True

Answers

  • Hello @mathieu.duarte

    What is the version of DatastreamDSWS in your environment?

    You can check the version from the following command:

    pip show DatastreamDSWS

    The latest version of the API is version 1.0.10 (as of Apr 2022), if you are using a lower version, please try to update the library.

  • Hi @wasin.w ,

    I'm already using 1.0.10 so I guess the problem does not come from this.

  • Hello @mathieu.duarte

    Thank you for the information. I can connect to DSWS using DatastreamDSWS 1.0.10.

    Are there any changes in your network?

    Please test with the http://product.datastream.com/DswsClient/Docs/TestRestV1.aspx page.

    First, use the Get Token method to get a token.

    Then, use the token with the Data (HTTP GET) method to get the data. Next, check the response.

  • @wasin.w ,

    I tested with your page and following the "Get Token" method I managed to obtain an example of result with both "Get Data" and the "Data (HTTP GET)"


  • Hi @Jirapongse ,

    Following the command "x = requests.post(url,json=myobj)" the station remains frozen with just: "DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): product.datastream.com:443"

    Nothing else happens.

    Would you know what I should do next ?

  • Hello @mathieu.duarte

    I have tested the steps suggested by @Jirapongse.The result is shown below.

    92031-test-result.png


    According to your statement, it may be a network issue between your Python environment and Datastream. I highly recommend you contact your local IT support to verify the network setting in your environment.

  • Thanks for your answers. Following some interaction with my local IT support we've adjusted some proxy parameters and it solved this problem.