开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

"438 : The application is now locked" and "326 : Unable to connect as the client id is already in use..." discontinued ?


 

Can anyone confirm that the errors in the subject have been discontinued in recent API versions ?

I have performed the following tests:

1) TWS locked:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "438 : The application is now locked"
- using an API 10.34 client to connect to TWS 10.19 or 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

2) client Id already in use:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "326 : Unable to connect as the client id is already in use. Retry with a unique client id."
- using an API 10.34 client to connect to TWS 10.19 or TWS 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

So it is clear that the issue is in the API, not in TWS.

The most recent TWS API versions do not provide the correct error message and instead always trigger error 502 in both scenarios of locked TWS and client Id already in use.

Can anyone confirm these findings ?

--


 

Which API language and operating system has your client used for your tests?
?
?
On Thu, Feb 20, 2025 at 07:04 AM, Orionn wrote:

Can anyone confirm that the errors in the subject have been discontinued in recent API versions ?

I have performed the following tests:

1) TWS locked:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "438 : The application is now locked"
- using an API 10.34 client to connect to TWS 10.19 or 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

2) client Id already in use:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "326 : Unable to connect as the client id is already in use. Retry with a unique client id."
- using an API 10.34 client to connect to TWS 10.19 or TWS 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

So it is clear that the issue is in the API, not in TWS.

The most recent TWS API versions do not provide the correct error message and instead always trigger error 502 in both scenarios of locked TWS and client Id already in use.

Can anyone confirm these findings ?

--


 

Hi 闯ü谤驳别苍. Please apologize for the missing information. It is Java on Windows.

--


 

I just checked the Java TWS API documentation and it looks like the "438 : The application is now locked." error has been deprecated which is very unfortunate.

--


 

When you say "using on old API client", do you have a feel for what API level that client supports? Do you still have the API source code?

I always run TWS/IBGW with "never lock", so that I cannot speak to error 438. Does the error message actually come from TWS (as in TWS records a message in the API log?) or does the API in the client assume TWS is locked based upon how the socket gets closed?

The earliest Java API I have used is 9.73.04 (API level 134) from 2017 and I have never seen error 326 upon clients attempting to connect with duplicate clientIDs. I always had client-side error 502 that is somewhat unspecific since it gets raised whenever the socket gets closed by TWS/IBGW or the operating system.

As you can see from the flow below, TWS/IGBW simply close the socket when the client sends a"StartAPI" message that contains a duplicate clientID. So I am wondering, whether your "old" client API locally raises error 326 upon socket closure after "StartAPI". I had thought about a patch like that for my framework since a more prescriptive error code would make a lot of sense in cases of duplicate clientIDs.


闯ü谤驳别苍

?

?
On Thu, Feb 20, 2025 at 07:04 AM, Orionn wrote:

Can anyone confirm that the errors in the subject have been discontinued in recent API versions ?

I have performed the following tests:

1) TWS locked:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "438 : The application is now locked"
- using an API 10.34 client to connect to TWS 10.19 or 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

2) client Id already in use:
- using an old API client to connect to TWS 10.19 or 10.34 correctly shows "326 : Unable to connect as the client id is already in use. Retry with a unique client id."
- using an API 10.34 client to connect to TWS 10.19 or TWS 10.34 shows: "502 | Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled ..."

So it is clear that the issue is in the API, not in TWS.

The most recent TWS API versions do not provide the correct error message and instead always trigger error 502 in both scenarios of locked TWS and client Id already in use.

Can anyone confirm these findings ?

--


 

I have just received the following update from IB regarding this issue:
"Please be aware that "Client ID is already in use" error will be brought back in the upcoming releases."

I have asked that other error messages that were dropped in recent versions of the API be brought back:
438 | The application is now locked
10141 | Paper trading disclaimer must first be accepted for API connection.
1300 | Socket port has been reset and this connection is being dropped. Please reconnect on the new port -7498

I have also asked that a new error is added for the scenario of 32 client applications already connected to TWS and no more connections being allowed.

In recent versions of the API, all these errors return the default 502 error which is not informative.

--