captin411 / ofxclient

Bank transaction downloader and python OFX client libraries
MIT License
261 stars 89 forks source link

Fails to connect to Charles Schwab Bank/Charles Schwab Brokerage on python3 #71

Open eamsden opened 5 years ago

eamsden commented 5 years ago

I have a laptop running Ubuntu 18.04 and python 2.7. On this laptop ofxclient 2.0.2 will successfully connect to Charles Schwab Bank and Charles Schwab brokerage and download my account data via OFX.

On my desktop, running NixOS unstable, ofxclient is run with Python 3.7.3 and is version 2.0.3 (latest from PyPI). Here I consistently receive the error:

  File "/<nixpath>/lib/python3.7/ssl.py", line 911, in read
    return self._sslobj.read(lne, buffer)
socket.timeout: The read operation timed out

It would seem that the ssl library is not properly making the connection. Note that this is not due to network errors, as the machines are on the same home network, can both ping the same hosts, and I have even run ofxclient concurrently on both.

Is there a known bug in the ssl library for python3 that is triggering this? Or is this an issue with ofxclient?

eamsden commented 4 years ago

Update: it turns out that newer versions of ofxclient (>2.0.2 I think) send a user-agent header, and a comma-separated "accept" header, both of which appear to confuse Schwab's OFX servers.

I was able to run ofxclient-2.0.4 on the machine where I currently had things working with 2.0.2, and verify that it broke. Then, setting institution.client_args.accept = "application/x-ofx" and institution.client_args.user_agent = False for each of my Schwab accounts allowed me to download them with ofxclient-2.0.4.

eamsden commented 4 years ago

It appears that this is addressed in #81