stoqey / ib

Interactive Brokers TWS/IB Gateway API client library for Node.js (TS)
https://stoqey.github.io/ib-doc/
MIT License
203 stars 47 forks source link

Error: Decoding error on undefined: unprocessed data left on queue #182

Open ramon1911 opened 1 year ago

ramon1911 commented 1 year ago

Hello, I'd just received this error while using the API: Error: Decoding error on undefined: unprocessed data left on queue (["20230727 02:49:21 EST",null]). Please report to https://github.com/stoqey/ib 505 It says to report it, so I am making this issue thread, feel free to close. To get this error, I am using the reqMatchingSymbols method on IBApi. In particular, I am using React to take a text input, and whenver the user types, then sending this request using your library to IB, and getting the response. Furthermore, I am using both the ib.connect and ib.disconnect method every time the user types a single character in the react field, and the data itself is passed through electron IPC, so there is a lot of friction.Therefore, this error is most likely due to a very large amount of requests in a short amount of time, as I'm getting a couple other errors such as "Error: No parser implementation found for token: undefined (166). 505". If you would like to see the code, please let me know. Thank you for your time.

rylorin commented 1 year ago

Hello, thanks for reporting. Can you tell us what parameters values for reqMatchingSymbols are raising this error? This info would help to reproduce and investigate. Thanks

ramon1911 commented 1 year ago

Hello, thanks for reporting. Can you tell us what parameters values for reqMatchingSymbols are raising this error? This info would help to reproduce and investigate. Thanks

Certainly. I used ib.once(EventName.nextValidId) to obtain the orderId, which I passed as the first input for reqMatching symbols, and for the second parameter I used a string, usually something like "aa" or "tsl", anything that would be the beginning of a ticker symbol.

However, it is worth it to note that I implemented a delay of 0.5ms between each reqMatchingSymbols request, and this had completely solved any errors I had using the API. Hope this helps.

rylorin commented 1 year ago

Hello, I created a new unit test to try to reproduce your bug: src/tests/unit/api/matching-symbols.test.ts Where I call reqMatchingSymbols 3 times with connection/disconnection each time but I didn't get your bug. If you have some time to edit the test to show up the problem, we could investigate. Thanks