question

Upvotes
Accepted
20 1 2 2

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.

pythondsws-apiconnectiontime-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.

Upvote
Accepted
79.2k 251 52 74

@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
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
24.7k 54 17 14

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.

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
20 1 2 2

Hi @wasin.w ,

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

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
24.7k 54 17 14

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.

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
20 1 2 2

@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)"


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
20 1 2 2

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 ?

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
24.7k 54 17 14

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.


92031-test-result.png (115.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.

Upvote
20 1 2 2

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

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.