jeog / TDAmeritradeAPI

Front-end library - with C, C++, Python, and Java interfaces - for the recently expanded TDAmeritrade API
GNU General Public License v3.0
238 stars 61 forks source link

credential_builder.py failed to write id file after TD Ameritrade authorization #10

Closed jack2050 closed 4 years ago

jack2050 commented 4 years ago

With jeog's latest push, now compilation on mac completed successfully, without any modification.

git clone https://github.com/jeog/TDAmeritradeAPI.git
cd TDAmeritradeAPI/Release2/
make all

Building target: libTDAmeritradeAPI.so
Invoking: GCC C++ Linker
g++ -shared -o "libTDAmeritradeAPI.so"   src/auth.o  src/common.o  src/curl_connect.o  src/error.o  src/tdma_connect.o  src/util.o  src/websocket_connect.o    src/execute/execute.o  src/execute/order_leg.o  src/execute/order_ticket.o    src/get/account.o  src/get/get.o  src/get/historical.o  src/get/instrument_info.o  src/get/market_hours.o  src/get/movers.o  src/get/options.o  src/get/quotes.o    src/streaming/streaming.o  src/streaming/streaming_session.o  src/streaming/streaming_subscriptions.o    uWebSockets/Epoll.o  uWebSockets/Extensions.o  uWebSockets/Group.o  uWebSockets/HTTPSocket.o  uWebSockets/Hub.o  uWebSockets/Networking.o  uWebSockets/Node.o  uWebSockets/Room.o  uWebSockets/Socket.o  uWebSockets/WebSocket.o    -lssl -lcrypto -lz -lcurl -lpthread -lutil -ldl -luv
Finished building target: libTDAmeritradeAPI.so

But somehow credential_builder.py could not finish writing the id file. The file was created with zero byte, but still was zero byte, after a long wait time.

tools $ python3 credential_builder.py --redirect-uri xxx --no-confirm-password --library-path xxx/libTDAmeritradeAPI.so xxx@AMER.OAUTHAP xxx xxx
- Failed to load: libTDAmeritradeAPI.so
- OSError: dlopen(libTDAmeritradeAPI.so, 6): image not found
- Use tdma_api.clib.init(path) to load manually
 + Extract Args...
   Library Path: xxx
   Redirect URI: xxx
   Client ID: xxx@AMER.OAUTHAP
   Credential Path: xxx
   Credential Password: *********

DevTools listening on ws://127.0.0.1:62767/devtools/browser/a1017276-fcb8-4d07-bf68-4d3b3t2bc235
[1125/114346.464327:ERROR:BudgetService.cpp(160)] Unable to connect to the Mojo BudgetService.
[1125/114407.838687:ERROR:BudgetService.cpp(160)] Unable to connect to the Mojo BudgetService.
jack2050 commented 4 years ago

debug shows credential_builder.py got stuck at line 121 cef.MessageLoop():

   120      browser.SetClientHandler(handler)
   121      cef.MessageLoop()  <--- 
   122      cef.Shutdown()

I am running latest cefpython3

tools $ pip3 freeze | grep cefpython3
cefpython3==66.0
jack2050 commented 4 years ago

The above issue still exists. But found a work around. For anyone who experiences similar issue in the future, here is what I did to work around the issue.

Use pdb module, pause and get the TD authorization code out before program hangs in RequestHandler(). Dumped code to a temp file. By reading in the code from temp file, and bypassing the hung part in main(), managed getting the credential ID.