question

Upvotes
Accepted
66 3 5 7

Error in proxy connection in DSWS API

Proxy connection DSWS.pngOne of our clients wants to connect through proxy when using DSWS API. His code currenlty looks like the attached, but getting following error msg:


HTTPSConnectionPool(host='product.datastream.com', port=443): Max retries exceeded with url: /DSWSClient/V1/DSService.svc/rest/GetToken (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

_get_json_Response : Exception Occured:

HTTPSConnectionPool(host='product.datastream.com', port=443): Max retries exceeded with url: /DSWSClient/V1/DSService.svc/rest/GetToken (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

get_data : Exception Occured

(<class 'Exception'>, Exception('Invalid Token Value'), <traceback object at 0x0000029FA02A7788>)

Traceback (most recent call last):

File "C:\ProgramData\Anaconda3\lib\site-packages\DatastreamDSWS\DS_Response.py", line 146, in get_data

raise Exception("Invalid Token Value")


Please assist. Thank you.

dsws-api
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.

Hello @bob.kim ,

Thank you for your participation in the forum.

Is the reply below satisfactory in resolving your query?

If yes, please click the 'Accept' text next to the appropriate reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

-AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,


AHS


Upvotes
Accepted
79.2k 251 52 74

@bob.kim

On Windows, the Datastream Python library uses the wincertstore package to load the Windows certificate file.

The code looks like this:

import requests
import wincertstore
cfile = wincertstore.CertFile()
cfile.addstore('CA')
cfile.addstore('ROOT')
cfile.addstore('MY')

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


x = requests.post(url, json = myobj, proxies={'http':proxy, 'https':proxy}, verify=cfile.name)


print(x.status_code)
print(x.text)


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.

Thanks again. So are you saying to add the code above to run the DSWS code?

Cheers,

Bob

@bob.kim

Yes, Datastream uses this requests.post method to send requests to the Datastream server.

Great! Cheers!
Upvotes
79.2k 251 52 74

@bob.kim

I can run the DSWS API through the proxy properly.

1654672742782.png

The problem may be specific to the client's environment. The client can contact the client's IT support team to verify the proxy settings.


1654672742782.png (24.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.

Upvotes
66 3 5 7

Thanks very much @Jirapongse Jirapongse. Would you by the way have any examples frequently experienced in regards to client's IT related issues in similar cases? That'd be greatly helpful. Thanks 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.

@bob.kim

The datastream server is on the Internet so any machines that can connect to the Internet can access the server.


Therefore, if clients are unable to connect to the datastream server, it could be a problem in network, proxy, or firewall settings.
Thanks again! Got it. Sorry one more question... so client is not having issues when tryning to connect to DSS using the same proxy, so i'm thinking it's not client's network proxy or firewall..


Would you have any other suggestions for the client to look into?

Cheers,

Bob

Upvotes
79.2k 251 52 74

@bob.kim

The client can try the following code.

import requests
#http_Response = requests.post(reqUrl, json=jsonRequest, proxies=self._proxy, verify=self._sslCer, timeout= self._timeout)
proxy="<proxy server>"
url = 'https://product.datastream.com/DSWSClient/V1/DSService.svc/rest/GetToken'
      
myobj = {"Password": "<password>", 
         "Properties": [{"Key": "__AppId", "Value": "PythonLib-1.1.0"}], 
         "UserName": "<username>"}

x = requests.post(url, json = myobj, proxies={'http':proxy, 'https':proxy})
print(x.status_code)
print(x.text)

The client may need to specify the certificate file in the sslCer parameter.

Datastream(username, password, config=None, dataSource=None, proxy=None, sslCer=None)

What operating system (Windows or Linux) is the client using?


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.

Cheers! i Will get back to you with client's OS


But can client directly use the above code, i.e. I'm guessing he will just need to replcace <proxy server>, <username> and <password>, but able to use the rest?

Lastly do you also directly support end users/clients via email?


Thanks again!

Correct. The client needs to change proxy server>, <username> and <password>.

To get direct support, the client needs to submit an issue to MyRefinitiv.

Hi Jira,

Thanks again for that. The client however came back with follow up question and information. Can you add your input one last time considering what the user mentioned below?

1. Client says the proxy issue only shows when he's in the office, and okay when working from home. But again, okay when using the proxy for his DSS API at work.

2. Client is using Windows, but now sure where the certificates are located. Would you be able to advise where it may be located?


Thanks again Jira!

Best,

Bob

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.