开云体育

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

port already in use


 

开云体育

screenshots included now


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?woensdag 12 maart 2025 8:16
Aan:[email protected] <[email protected]>
Onderwerp:?FW: [ibc] port already in use
?
Hi Richard,
as mentioned yesterday I added some comments in my own logfile to see what happens after the restart.?
This morning I saw the same error message, and again twice the same instance : account -86 is open and normally reacting. The same account -86 is still (or again?) there, but the screen is grey and it does not respond to anything. You will find 2 screenshots, both with the grey screen. On the first my pointer is in the lower tab menu above the account -86, so the account number is shown. On the second, my pointer is above another account tab (7 tabs more to the left or to the right), showing the same account number. That's the best I could get to show you what I try to tell.
My code in the background stops checking after 22:00 and does not start before 8:45 in the morning. The auto-restart is just before midnight. I took the screenshot this morning around 8:30. So the code did not do anything, which is confirmed by my logfile. (the code runs "/opt/ibc/twsstart4080.sh" every 5' during the day, from 8:45 untill 22:00 : as far as I know this will open the 4080 instance if not open yet, or do nothing if already open, please correct me if I'm wrong).
If you can't think of any other reason, I will change the restart time and try to see what happens at that time.

Thanks anyway,
rik


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?dinsdag 11 maart 2025 16:18
Aan:[email protected] <[email protected]>
Onderwerp:?Re: [ibc] port already in use
?
Thanks for your reaction, Richard.
I have indeed running a code that is checking if some instance has been closed while it shouldn't. This also runs for many years now. I will add comment lines to my logfile to check if this code tries to start a new instance at some time where the ibc-log says that it is open already. Anyway, thanks for the tip.
best regards
rik

Van:[email protected] <[email protected]> namens Richard L King <rlking@...>
Verzonden:?dinsdag 11 maart 2025 10:51
Aan:[email protected] <[email protected]>
Onderwerp:?Re: [ibc] port already in use
?

rik

?

As far as I can tell from the logfile, IBC is behaving fine. The restart does complete successfully, and then at 2025-03-11 08:40:09:452 the program shuts down: I presume this is because at this point you closed it manually, because it was displaying the ‘port already in use’ dialog?

?

All the evidence points to there really being another instance configured with the same API port. When the first instance closes for restart at 2025-03-10 23:49:02, it really has shut down – there is no possibility that it’s still running. And yet you say one instance (always the same) did not close as it should (it is still open, and does not react on anything)’. Can you get a screenshot showing this supposedly blocked instance, the new instance, and the error message together?

?

What seems most likely to me is that the original instance has indeed shut down and restarted successfully (which is what the log shows), and another new ?instance has somehow been started and it is this one that is showing the error dialog. I have no idea why that might have happened: perhaps you are doing periodic restarts using Task Scheduler to catch cases where IBC/TWS has crashed, and this just happens to be at the same time as the auto-restart?

?

So from my point of view I can’t see anything wrong here: there doesn’t appear to be an IBC problem. However I do note that you’re running a rather old version of IBC, and I would encourage you to move to the latest version.

?

Richard

?

?

From:[email protected] <[email protected]> On Behalf Of rik . via groups.io
Sent:?11 March 2025 08:03
To:[email protected]
Subject:?[ibc] port already in use

?

Hello,

I'm using ibc for years now, starting multipal instances on sunday or monday, and let them restart overnight until the weekend. Since a few weeks I'm getting the error "port already in use" (see printscreen) on the first restart moment, so I see it on monday or tuesday morning. This is because one instance (always the same) did not close as it should (it is still open, and does not react on anything). The new instance opens well but cannot use the API port as it seems to be still in use by the blocked instance. The only thing I can do is close everything but the blocked instance, restart my pc and start all over again. This happens only after the first overnight restart. The rest of the week everything ngoes fine (until now...).

I have no clue what or where to look for. The log is attached (this week I started on monday, so I saw the error this tuesday morning). Every help is welcome. Thanks,

rik


 

开云体育

I don’t understand these blue tabs with the account number in them. Where do they come from? And what do you mean by ‘7 tabs more to the left or to the right’? In fact I don’t really understand what this paragraph is trying to say.

?

Let’s summarise what we know (please say if you think I’ve got some of this wrong):

?

  1. There are incontrovertibly two (or more?) instances of TWS configured with the same API port number.
  2. The two instances must be configured with different accounts, because you have ExistingSessionDetectedAction=primaryoverride in config.ini, and this won’t allow another login with the same user account: the original instance will be automatically closed down, and the ‘port already in use’ dialog disappears.
  3. The two instances must use different config.ini files, because the twsstart.sh script won’t allow another one using the same config.ini to start.
  4. You say you’ve been running this configuration for a long time (years?), except that you’ve upgraded to TWS 1030 at some point.
  5. Everything has been fine until recently.
  6. Nothing has changed ????
  7. Auto-restart worked flawlessly according to the log. The ibcstart.sh script only starts the new instance once the original one has exited: it’s inconceivable that Linux could somehow have not terminated the program but returned a success exit code to the script. So the original instance cannot be one of the conflicting instances. The restarted instance presumably is one of the conflicting instances, though there is nothing in the log that obviously confirms this.
  8. This only seems to happen the first time IBC is run during a week.

?

After quite a bit of experimenting, I haven’t managed to work out a scenario that could adequately explain all this.

?

However I do think it must be the case that another instance has been mis-configured with the wrong API port number - you said at the start that you run multiple instances. Can you please double-check this.

?

?

?

?

From: [email protected] <[email protected]> On Behalf Of rik . via groups.io
Sent: 12 March 2025 08:28
To: [email protected]
Subject: Re: [ibc] port already in use

?

screenshots included now

?


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?woensdag 12 maart 2025 8:16
Aan:?[email protected] <[email protected]>
Onderwerp:?FW: [ibc] port already in use

?

Hi Richard,

as mentioned yesterday I added some comments in my own logfile to see what happens after the restart.?

This morning I saw the same error message, and again twice the same instance : account -86 is open and normally reacting. The same account -86 is still (or again?) there, but the screen is grey and it does not respond to anything. You will find 2 screenshots, both with the grey screen. On the first my pointer is in the lower tab menu above the account -86, so the account number is shown. On the second, my pointer is above another account tab (7 tabs more to the left or to the right), showing the same account number. That's the best I could get to show you what I try to tell.

My code in the background stops checking after 22:00 and does not start before 8:45 in the morning. The auto-restart is just before midnight. I took the screenshot this morning around 8:30. So the code did not do anything, which is confirmed by my logfile. (the code runs "/opt/ibc/twsstart4080.sh" every 5' during the day, from 8:45 untill 22:00 : as far as I know this will open the 4080 instance if not open yet, or do nothing if already open, please correct me if I'm wrong).

If you can't think of any other reason, I will change the restart time and try to see what happens at that time.

?

Thanks anyway,

rik

?


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?dinsdag 11 maart 2025 16:18
Aan:?[email protected] <[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

Thanks for your reaction, Richard.

I have indeed running a code that is checking if some instance has been closed while it shouldn't. This also runs for many years now. I will add comment lines to my logfile to check if this code tries to start a new instance at some time where the ibc-log says that it is open already. Anyway, thanks for the tip.

best regards

rik


Van:?[email protected] <[email protected]> namens Richard L King <rlking@...>
Verzonden:?dinsdag 11 maart 2025 10:51
Aan:?[email protected] <[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

rik

?

As far as I can tell from the logfile, IBC is behaving fine. The restart does complete successfully, and then at 2025-03-11 08:40:09:452 the program shuts down: I presume this is because at this point you closed it manually, because it was displaying the ‘port already in use’ dialog?

?

All the evidence points to there really being another instance configured with the same API port. When the first instance closes for restart at 2025-03-10 23:49:02, it really has shut down – there is no possibility that it’s still running. And yet you say one instance (always the same) did not close as it should (it is still open, and does not react on anything)’. Can you get a screenshot showing this supposedly blocked instance, the new instance, and the error message together?

?

What seems most likely to me is that the original instance has indeed shut down and restarted successfully (which is what the log shows), and another new ?instance has somehow been started and it is this one that is showing the error dialog. I have no idea why that might have happened: perhaps you are doing periodic restarts using Task Scheduler to catch cases where IBC/TWS has crashed, and this just happens to be at the same time as the auto-restart?

?

So from my point of view I can’t see anything wrong here: there doesn’t appear to be an IBC problem. However I do note that you’re running a rather old version of IBC, and I would encourage you to move to the latest version.

?

Richard

?

?

From:?[email protected] <[email protected]> On Behalf Of rik . via groups.io
Sent:?11 March 2025 08:03
To:?[email protected]
Subject:?[ibc] port already in use

?

Hello,

I'm using ibc for years now, starting multipal instances on sunday or monday, and let them restart overnight until the weekend. Since a few weeks I'm getting the error "port already in use" (see printscreen) on the first restart moment, so I see it on monday or tuesday morning. This is because one instance (always the same) did not close as it should (it is still open, and does not react on anything). The new instance opens well but cannot use the API port as it seems to be still in use by the blocked instance. The only thing I can do is close everything but the blocked instance, restart my pc and start all over again. This happens only after the first overnight restart. The rest of the week everything ngoes fine (until now...).

I have no clue what or where to look for. The log is attached (this week I started on monday, so I saw the error this tuesday morning). Every help is welcome. Thanks,

rik


 

开云体育

Hi Richard,
you asked for a screenshot, but I can't explain in english?what you see?(sorry for that, I'm missing the right words). Let me try to explain the "blue tabs" again : at the bottom of the screen you see many tabs : starting from left I see "linux mint", "file mngr", "firefox" (orange colour), "file mngr", "U7"(green), etc. The "U7" tab is an IB TWS window with account number U7...86". How do I know this ? When I hover my mouse pointer over it, a blue popup appears, showing the full description : see screenshot API-86.2.png. Seven tabs more to the right, you see another green tab "U7" which is another IB TWS window with the SAME account number (see? the other screenshot). This second green tab is lightened a bit, so it is shown on the screen, which is grey because TWS is frozen. (the green logo on the tab is from a local broker that is using the IB software).

The problem always occurs with account U...86 that is using port 4080.

  1. When the problem occurs, there are two windows named "U...86" : one window is frozen, the other is functioning normally but the error popup warns me that there is a problem with the API. I don't know if his popup is about the functioning TWS, or about the frozen one ...
    I checked all files like configPORT.ini and gwstartPORT.sh and twsstartPORT.sh : I made no mistake with the portnumbers (PORT=4080, 4081 etc). As mentioned, my code runs "/opt/ibc/twsstartPORT.sh" every 5' during the day, from 8:45 untill 22:00 for every port I'm using (2 TWS + 3 gateway currently, so 5 different account numbers and 5 different ports : on the screenshot you can see the 3 gateway tabs ("gw...") and the 5 IBC tabs, more to the right, the other TWS is the red tab with the small IB logo "U1.." : so I see 3 TWS tabs which is "impossible").
  2. The two windows mentioned in 1. show me the same account number, when I hover my mouse pointer over the tab of the window.
  3. There is only one config4080.ini file on my pc with the path ~/Jts4080 in it. All other configPORT.ini files have their own path ~/JtsPORT.
  4. I was running this already when it was called IBcontroller. Last 2 updates I did were IB related (16/11/24 and 18/1/25). I'm wondering now whether the problem started after this last update (from 1030.1q to 1030.1t, because IB forced me to).
  5. It started "weeks ago", just once a week, on monday morning (after startup on sunday morning).
  6. see 4
  7. ?
  8. I'm sure it's only on monday, when I start on sunday. I reboot on monday morning and then I'm fine for the week. Except this week : I started on monday, so the problem was there on tuesday morning. I rebooted and started again. But on wednesday, the problem was there again ... Yesterday I changed the autorestart time in TWS to "8h40" : this thursday morning no problem occurred while I was watching.

Without other suggestions, I will try to end the week without changes (and hopefully, without errors). On sunday I will run my startup code only once, and shut it down then for the rest of the week. If that doesn't help, I'll try a complete update (IB + ibc) as soon as I have a free weekend.

rgds
rik



Van:[email protected] <[email protected]> namens Richard L King <rlking@...>
Verzonden:?woensdag 12 maart 2025 19:00
Aan:[email protected] <[email protected]>
Onderwerp:?Re: [ibc] port already in use
?

I don’t understand these blue tabs with the account number in them. Where do they come from? And what do you mean by ‘7 tabs more to the left or to the right’? In fact I don’t really understand what this paragraph is trying to say.

?

Let’s summarise what we know (please say if you think I’ve got some of this wrong):

?

  1. There are incontrovertibly two (or more?) instances of TWS configured with the same API port number.
  2. The two instances must be configured with different accounts, because you have ExistingSessionDetectedAction=primaryoverride in config.ini, and this won’t allow another login with the same user account: the original instance will be automatically closed down, and the ‘port already in use’ dialog disappears.
  3. The two instances must use different config.ini files, because the twsstart.sh script won’t allow another one using the same config.ini to start.
  4. You say you’ve been running this configuration for a long time (years?), except that you’ve upgraded to TWS 1030 at some point.
  5. Everything has been fine until recently.
  6. Nothing has changed ????
  7. Auto-restart worked flawlessly according to the log. The ibcstart.sh script only starts the new instance once the original one has exited: it’s inconceivable that Linux could somehow have not terminated the program but returned a success exit code to the script. So the original instance cannot be one of the conflicting instances. The restarted instance presumably is?one of the conflicting instances, though there is nothing in the log that obviously confirms this.
  8. This only seems to happen the first time IBC is run during a week.

?

After quite a bit of experimenting, I haven’t managed to work out a scenario that could adequately explain all this.

?

However I do think it must be the case that another instance has been mis-configured with the wrong API port number - you said at the start that you run multiple instances. Can you please double-check this.

?

?

?

?

From:[email protected] <[email protected]> On Behalf Of rik . via groups.io
Sent:?12 March 2025 08:28
To:[email protected]
Subject:?Re: [ibc] port already in use

?

screenshots included now

?


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?woensdag 12 maart 2025 8:16
Aan:?
[email protected]?<[email protected]>
Onderwerp:?FW: [ibc] port already in use

?

Hi Richard,

as mentioned yesterday I added some comments in my own logfile to see what happens after the restart.?

This morning I saw the same error message, and again twice the same instance : account -86 is open and normally reacting. The same account -86 is still (or again?) there, but the screen is grey and it does not respond to anything. You will find 2 screenshots, both with the grey screen. On the first my pointer is in the lower tab menu above the account -86, so the account number is shown. On the second, my pointer is above another account tab (7 tabs more to the left or to the right), showing the same account number. That's the best I could get to show you what I try to tell.

My code in the background stops checking after 22:00 and does not start before 8:45 in the morning. The auto-restart is just before midnight. I took the screenshot this morning around 8:30. So the code did not do anything, which is confirmed by my logfile. (the code runs "/opt/ibc/twsstart4080.sh" every 5' during the day, from 8:45 untill 22:00 : as far as I know this will open the 4080 instance if not open yet, or do nothing if already open, please correct me if I'm wrong).

If you can't think of any other reason, I will change the restart time and try to see what happens at that time.

?

Thanks anyway,

rik

?


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?dinsdag 11 maart 2025 16:18
Aan:?
[email protected]?<[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

Thanks for your reaction, Richard.

I have indeed running a code that is checking if some instance has been closed while it shouldn't. This also runs for many years now. I will add comment lines to my logfile to check if this code tries to start a new instance at some time where the ibc-log says that it is open already. Anyway, thanks for the tip.

best regards

rik


Van:?[email protected]?<[email protected]> namens Richard L King <rlking@...>
Verzonden:?dinsdag 11 maart 2025 10:51
Aan:?
[email protected]?<[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

rik

?

As far as I can tell from the logfile, IBC is behaving fine. The restart does complete successfully, and then at 2025-03-11 08:40:09:452 the program shuts down: I presume this is because at this point you closed it manually, because it was displaying the ‘port already in use’ dialog?

?

All the evidence points to there really being another instance configured with the same API port. When the first instance closes for restart at 2025-03-10 23:49:02, it really has shut down – there is no possibility that it’s still running. And yet you say one instance (always the same) did not close as it should (it is still open, and does not react on anything)’. Can you get a screenshot showing this supposedly blocked instance, the new instance, and the error message together?

?

What seems most likely to me is that the original instance has indeed shut down and restarted successfully (which is what the log shows), and another new ?instance has somehow been started and it is this one that is showing the error dialog. I have no idea why that might have happened: perhaps you are doing periodic restarts using Task Scheduler to catch cases where IBC/TWS has crashed, and this just happens to be at the same time as the auto-restart?

?

So from my point of view I can’t see anything wrong here: there doesn’t appear to be an IBC problem. However I do note that you’re running a rather old version of IBC, and I would encourage you to move to the latest version.

?

Richard

?

?

From:?[email protected]?<[email protected]> On Behalf Of rik . via groups.io
Sent:?11 March 2025 08:03
To:?
[email protected]
Subject:?[ibc] port already in use

?

Hello,

I'm using ibc for years now, starting multipal instances on sunday or monday, and let them restart overnight until the weekend. Since a few weeks I'm getting the error "port already in use" (see printscreen) on the first restart moment, so I see it on monday or tuesday morning. This is because one instance (always the same) did not close as it should (it is still open, and does not react on anything). The new instance opens well but cannot use the API port as it seems to be still in use by the blocked instance. The only thing I can do is close everything but the blocked instance, restart my pc and start all over again. This happens only after the first overnight restart. The rest of the week everything ngoes fine (until now...).

I have no clue what or where to look for. The log is attached (this week I started on monday, so I saw the error this tuesday morning). Every help is welcome. Thanks,

rik


 

开云体育

Ah, I understand. The screenshots were too fuzzy for me to make out the text and icons on the tabs, so it wasn’t at all clear to me that the blue popups were just from hovering over the items on the dock. I do have an Ubuntu installation, but only use it for IBC testing, and it has a rather different layout, so I didn’t make the obvious connection.

?

By the way, please don’t apologise about your English: it seems excellent to me. I don’t know what your native language is, but I can guarantee that I don’t speak a word of it (unless it’s Russian or French, and even then I need a dictionary and a lot of help!...).

?

You can easily tell which TWS owns the error popup: just kill the frozen one, and if the popup remains it must belong to the working one, otherwise the frozen one.

?

One thing you could try doing is to modify the /opt/ibc/scripts/ibcstart.sh script to leave a lengthy delay between TWS hutting down at restart time and the script starting the new instance. Look for these lines very near the end of the script (I don’t know what the actual line numbers are for the version you’re running):

?

??????????????? # wait a few seconds before restarting

??????????????? echo IBC will restart shortly

??????????????? echo sleep 2

?

and change “echo sleep 2” to something much longer like “echo sleep 60”. Make sure you know which tab on your dock is for the 4080 port. When it gets to restart time, you should see that TWS shut down, but the associated banner (xterm) window will still be there. You now have 60 seconds to check that the original instance really has gone, and you should now only see 2 TWS tabs (assuming your other TWS instances aren’t restarting at the same time). If the original TWS doesn’t shut down, then the laws of physics must have changed: it’s inconceivable that the “echo sleep 60” statement could be reached without that process terminating. But perhaps you’ll see another unexpected instance appear, a rogue one – this has to be the source of the problem. Then when the 60 seconds is up, the restarting TWS will be fired up, and then you would see the ‘port already in use’ dialog.

?

I wonder whether such a rogue instance might be because there is a crontab entry that runs the account -86 port 4080 TWS lying around somewhere, that you used at some stage for testing or whatever.

?

Another thing you should perhaps do, before getting to the restart time, is to try and account for all the IBC processes in the ps listing: there should be one for each TWS and Gateway that you start. Any extra ones need to be investigated. You can get a list using this command:

?

ps aux | grep ‘IBC.jar' > ~/ps-ibc

?

That’s it for now.

?

R.

?

?

From: [email protected] <[email protected]> On Behalf Of rik . via groups.io
Sent: 13 March 2025 08:37
To: [email protected]
Subject: Re: [ibc] port already in use

?

Hi Richard,

you asked for a screenshot, but I can't explain in english?what you see?(sorry for that, I'm missing the right words). Let me try to explain the "blue tabs" again : at the bottom of the screen you see many tabs : starting from left I see "linux mint", "file mngr", "firefox" (orange colour), "file mngr", "U7"(green), etc. The "U7" tab is an IB TWS window with account number U7...86". How do I know this ? When I hover my mouse pointer over it, a blue popup appears, showing the full description : see screenshot API-86.2.png. Seven tabs more to the right, you see another green tab "U7" which is another IB TWS window with the SAME account number (see? the other screenshot). This second green tab is lightened a bit, so it is shown on the screen, which is grey because TWS is frozen. (the green logo on the tab is from a local broker that is using the IB software).

?

The problem always occurs with account U...86 that is using port 4080.

?

  1. When the problem occurs, there are two windows named "U...86" : one window is frozen, the other is functioning normally but the error popup warns me that there is a problem with the API. I don't know if his popup is about the functioning TWS, or about the frozen one ...

I checked all files like configPORT.ini and gwstartPORT.sh and twsstartPORT.sh : I made no mistake with the portnumbers (PORT=4080, 4081 etc). As mentioned, my code runs "/opt/ibc/twsstartPORT.sh" every 5' during the day, from 8:45 untill 22:00 for every port I'm using (2 TWS + 3 gateway currently, so 5 different account numbers and 5 different ports : on the screenshot you can see the 3 gateway tabs ("gw...") and the 5 IBC tabs, more to the right, the other TWS is the red tab with the small IB logo "U1.." : so I see 3 TWS tabs which is "impossible").

  1. The two windows mentioned in 1. show me the same account number, when I hover my mouse pointer over the tab of the window.
  1. There is only one config4080.ini file on my pc with the path ~/Jts4080 in it. All other configPORT.ini files have their own path ~/JtsPORT.
  1. I was running this already when it was called IBcontroller. Last 2 updates I did were IB related (16/11/24 and 18/1/25). I'm wondering now whether the problem started after this last update (from 1030.1q to 1030.1t, because IB forced me to).
  1. It started "weeks ago", just once a week, on monday morning (after startup on sunday morning).
  1. see 4
  1. ?
  1. I'm sure it's only on monday, when I start on sunday. I reboot on monday morning and then I'm fine for the week. Except this week : I started on monday, so the problem was there on tuesday morning. I rebooted and started again. But on wednesday, the problem was there again ... Yesterday I changed the autorestart time in TWS to "8h40" : this thursday morning no problem occurred while I was watching.

?

Without other suggestions, I will try to end the week without changes (and hopefully, without errors). On sunday I will run my startup code only once, and shut it down then for the rest of the week. If that doesn't help, I'll try a complete update (IB + ibc) as soon as I have a free weekend.

?

rgds

rik

?

?


Van:?[email protected] <[email protected]> namens Richard L King <rlking@...>
Verzonden:?woensdag 12 maart 2025 19:00
Aan:?[email protected] <[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

I don’t understand these blue tabs with the account number in them. Where do they come from? And what do you mean by ‘7 tabs more to the left or to the right’? In fact I don’t really understand what this paragraph is trying to say.

?

Let’s summarise what we know (please say if you think I’ve got some of this wrong):

?

  1. There are incontrovertibly two (or more?) instances of TWS configured with the same API port number.
  2. The two instances must be configured with different accounts, because you have ExistingSessionDetectedAction=primaryoverride in config.ini, and this won’t allow another login with the same user account: the original instance will be automatically closed down, and the ‘port already in use’ dialog disappears.
  3. The two instances must use different config.ini files, because the twsstart.sh script won’t allow another one using the same config.ini to start.
  4. You say you’ve been running this configuration for a long time (years?), except that you’ve upgraded to TWS 1030 at some point.
  5. Everything has been fine until recently.
  6. Nothing has changed ????
  7. Auto-restart worked flawlessly according to the log. The ibcstart.sh script only starts the new instance once the original one has exited: it’s inconceivable that Linux could somehow have not terminated the program but returned a success exit code to the script. So the original instance cannot be one of the conflicting instances. The restarted instance presumably is?one of the conflicting instances, though there is nothing in the log that obviously confirms this.
  8. This only seems to happen the first time IBC is run during a week.

?

After quite a bit of experimenting, I haven’t managed to work out a scenario that could adequately explain all this.

?

However I do think it must be the case that another instance has been mis-configured with the wrong API port number - you said at the start that you run multiple instances. Can you please double-check this.

?

?

?

?

From:?[email protected] <[email protected]> On Behalf Of rik . via groups.io
Sent:?12 March 2025 08:28
To:?[email protected]
Subject:?Re: [ibc] port already in use

?

screenshots included now

?


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?woensdag 12 maart 2025 8:16
Aan:?
[email protected]?<[email protected]>
Onderwerp:?FW: [ibc] port already in use

?

Hi Richard,

as mentioned yesterday I added some comments in my own logfile to see what happens after the restart.?

This morning I saw the same error message, and again twice the same instance : account -86 is open and normally reacting. The same account -86 is still (or again?) there, but the screen is grey and it does not respond to anything. You will find 2 screenshots, both with the grey screen. On the first my pointer is in the lower tab menu above the account -86, so the account number is shown. On the second, my pointer is above another account tab (7 tabs more to the left or to the right), showing the same account number. That's the best I could get to show you what I try to tell.

My code in the background stops checking after 22:00 and does not start before 8:45 in the morning. The auto-restart is just before midnight. I took the screenshot this morning around 8:30. So the code did not do anything, which is confirmed by my logfile. (the code runs "/opt/ibc/twsstart4080.sh" every 5' during the day, from 8:45 untill 22:00 : as far as I know this will open the 4080 instance if not open yet, or do nothing if already open, please correct me if I'm wrong).

If you can't think of any other reason, I will change the restart time and try to see what happens at that time.

?

Thanks anyway,

rik

?


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?dinsdag 11 maart 2025 16:18
Aan:?
[email protected]?<[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

Thanks for your reaction, Richard.

I have indeed running a code that is checking if some instance has been closed while it shouldn't. This also runs for many years now. I will add comment lines to my logfile to check if this code tries to start a new instance at some time where the ibc-log says that it is open already. Anyway, thanks for the tip.

best regards

rik


Van:?[email protected]?<[email protected]> namens Richard L King <rlking@...>
Verzonden:?dinsdag 11 maart 2025 10:51
Aan:?
[email protected]?<[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

rik

?

As far as I can tell from the logfile, IBC is behaving fine. The restart does complete successfully, and then at 2025-03-11 08:40:09:452 the program shuts down: I presume this is because at this point you closed it manually, because it was displaying the ‘port already in use’ dialog?

?

All the evidence points to there really being another instance configured with the same API port. When the first instance closes for restart at 2025-03-10 23:49:02, it really has shut down – there is no possibility that it’s still running. And yet you say one instance (always the same) did not close as it should (it is still open, and does not react on anything)’. Can you get a screenshot showing this supposedly blocked instance, the new instance, and the error message together?

?

What seems most likely to me is that the original instance has indeed shut down and restarted successfully (which is what the log shows), and another new ?instance has somehow been started and it is this one that is showing the error dialog. I have no idea why that might have happened: perhaps you are doing periodic restarts using Task Scheduler to catch cases where IBC/TWS has crashed, and this just happens to be at the same time as the auto-restart?

?

So from my point of view I can’t see anything wrong here: there doesn’t appear to be an IBC problem. However I do note that you’re running a rather old version of IBC, and I would encourage you to move to the latest version.

?

Richard

?

?

From:?[email protected]?<[email protected]> On Behalf Of rik . via groups.io
Sent:?11 March 2025 08:03
To:?[email protected]
Subject:?[ibc] port already in use

?

Hello,

I'm using ibc for years now, starting multipal instances on sunday or monday, and let them restart overnight until the weekend. Since a few weeks I'm getting the error "port already in use" (see printscreen) on the first restart moment, so I see it on monday or tuesday morning. This is because one instance (always the same) did not close as it should (it is still open, and does not react on anything). The new instance opens well but cannot use the API port as it seems to be still in use by the blocked instance. The only thing I can do is close everything but the blocked instance, restart my pc and start all over again. This happens only after the first overnight restart. The rest of the week everything ngoes fine (until now...).

I have no clue what or where to look for. The log is attached (this week I started on monday, so I saw the error this tuesday morning). Every help is welcome. Thanks,

rik


 

开云体育

Hi Richard,

I'm sorry for the delay in response, due to "several circumstances" beyond this topic.

Since the problem is there I changed the autorestart time for "the problematic account" in TWS to "8h40" so that I can watch the pc screen during restart.

Since your last reply I did the following :

*the ps output looks normal everytime I check : 1 line for each instance, 5 lines in total in my current configuration
*following your advice, I changed the "echo sleep 2" line to "echo sleep 60" in the file/opt/ibc/scripts/ibcstart.sh. (I don't understand what this is exactly changing. I expected a delay between closing and opening the instance, but I don't see a delay anywhere. Also your description of what I should see on my screen during restart is a bit unclear to me.)

Anyway, the good news is : since then every restart again goes as it should, for (I think) 3 weeks in a row now. So for me, this problem is solved (thx a lot !!), although I'm afraid I'm not completely with you.

best rgds,
rik


Van:[email protected] <[email protected]> namens Richard L King <rlking@...>
Verzonden:?donderdag 13 maart 2025 12:17
Aan:[email protected] <[email protected]>
Onderwerp:?Re: [ibc] port already in use
?

Ah, I understand. The screenshots were too fuzzy for me to make out the text and icons on the tabs, so it wasn’t at all clear to me that the blue popups were just from hovering over the items on the dock. I do have an Ubuntu installation, but only use it for IBC testing, and it has a rather different layout, so I didn’t make the obvious connection.

?

By the way, please don’t apologise about your English: it seems excellent to me. I don’t know what your native language is, but I can guarantee that I don’t speak a word of it (unless it’s Russian or French, and even then I need a dictionary and a lot of help!...).

?

You can easily tell which TWS owns the error popup: just kill the frozen one, and if the popup remains it must belong to the working one, otherwise the frozen one.

?

One thing you could try doing is to modify the /opt/ibc/scripts/ibcstart.sh script to leave a lengthy delay between TWS hutting down at restart time and the script starting the new instance. Look for these lines very near the end of the script (I don’t know what the actual line numbers are for the version you’re running):

?

??????????????? # wait a few seconds before restarting

??????????????? echo IBC will restart shortly

??????????????? echo sleep 2

?

and change “echo sleep 2” to something much longer like “echo sleep 60”. Make sure you know which tab on your dock is for the 4080 port. When it gets to restart time, you should see that TWS shut down, but the associated banner (xterm) window will still be there. You now have 60 seconds to check that the original instance really has gone, and you should now only see 2 TWS tabs (assuming your other TWS instances aren’t restarting at the same time). If the original TWS doesn’t shut down, then the laws of physics must have changed: it’s inconceivable that the “echo sleep 60” statement could be reached without that process terminating. But perhaps you’ll see another unexpected instance appear, a rogue one – this has to be the source of the problem. Then when the 60 seconds is up, the restarting TWS will be fired up, and then you would see the ‘port already in use’ dialog.

?

I wonder whether such a rogue instance might be because there is a crontab entry that runs the account -86 port 4080 TWS lying around somewhere, that you used at some stage for testing or whatever.

?

Another thing you should perhaps do, before getting to the restart time, is to try and account for all the IBC processes in the ps listing: there should be one for each TWS and Gateway that you start. Any extra ones need to be investigated. You can get a list using this command:

?

ps aux | grep ‘IBC.jar' > ~/ps-ibc

?

That’s it for now.

?

R.

?

?

From:[email protected] <[email protected]> On Behalf Of rik . via groups.io
Sent:?13 March 2025 08:37
To:[email protected]
Subject:?Re: [ibc] port already in use

?

Hi Richard,

you asked for a screenshot, but I can't explain in english?what you see?(sorry for that, I'm missing the right words). Let me try to explain the "blue tabs" again : at the bottom of the screen you see many tabs : starting from left I see "linux mint", "file mngr", "firefox" (orange colour), "file mngr", "U7"(green), etc. The "U7" tab is an IB TWS window with account number U7...86". How do I know this ? When I hover my mouse pointer over it, a blue popup appears, showing the full description : see screenshot API-86.2.png. Seven tabs more to the right, you see another green tab "U7" which is another IB TWS window with the SAME account number (see? the other screenshot). This second green tab is lightened a bit, so it is shown on the screen, which is grey because TWS is frozen. (the green logo on the tab is from a local broker that is using the IB software).

?

The problem always occurs with account U...86 that is using port 4080.

?

  1. When the problem occurs, there are two windows named "U...86" : one window is frozen, the other is functioning normally but the error popup warns me that there is a problem with the API. I don't know if his popup is about the functioning TWS, or about the frozen one ...

I checked all files like configPORT.ini and gwstartPORT.sh and twsstartPORT.sh : I made no mistake with the portnumbers (PORT=4080, 4081 etc). As mentioned, my code runs "/opt/ibc/twsstartPORT.sh" every 5' during the day, from 8:45 untill 22:00 for every port I'm using (2 TWS + 3 gateway currently, so 5 different account numbers and 5 different ports : on the screenshot you can see the 3 gateway tabs ("gw...") and the 5 IBC tabs, more to the right, the other TWS is the red tab with the small IB logo "U1.." : so I see 3 TWS tabs which is "impossible").

  1. The two windows mentioned in 1. show me the same account number, when I hover my mouse pointer over the tab of the window.
  2. There is only one config4080.ini file on my pc with the path ~/Jts4080 in it. All other configPORT.ini files have their own path ~/JtsPORT.
  3. I was running this already when it was called IBcontroller. Last 2 updates I did were IB related (16/11/24 and 18/1/25). I'm wondering now whether the problem started after this last update (from 1030.1q to 1030.1t, because IB forced me to).
  4. It started "weeks ago", just once a week, on monday morning (after startup on sunday morning).
  5. see 4
  6. ?
  7. I'm sure it's only on monday, when I start on sunday. I reboot on monday morning and then I'm fine for the week. Except this week : I started on monday, so the problem was there on tuesday morning. I rebooted and started again. But on wednesday, the problem was there again ... Yesterday I changed the autorestart time in TWS to "8h40" : this thursday morning no problem occurred while I was watching.

?

Without other suggestions, I will try to end the week without changes (and hopefully, without errors). On sunday I will run my startup code only once, and shut it down then for the rest of the week. If that doesn't help, I'll try a complete update (IB + ibc) as soon as I have a free weekend.

?

rgds

rik

?

?


Van:?[email protected]?<[email protected]> namens Richard L King <rlking@...>
Verzonden:?woensdag 12 maart 2025 19:00
Aan:?
[email protected]?<[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

I don’t understand these blue tabs with the account number in them. Where do they come from? And what do you mean by ‘7 tabs more to the left or to the right’? In fact I don’t really understand what this paragraph is trying to say.

?

Let’s summarise what we know (please say if you think I’ve got some of this wrong):

?

  1. There are incontrovertibly two (or more?) instances of TWS configured with the same API port number.
  2. The two instances must be configured with different accounts, because you have ExistingSessionDetectedAction=primaryoverride in config.ini, and this won’t allow another login with the same user account: the original instance will be automatically closed down, and the ‘port already in use’ dialog disappears.
  3. The two instances must use different config.ini files, because the twsstart.sh script won’t allow another one using the same config.ini to start.
  4. You say you’ve been running this configuration for a long time (years?), except that you’ve upgraded to TWS 1030 at some point.
  5. Everything has been fine until recently.
  6. Nothing has changed ????
  7. Auto-restart worked flawlessly according to the log. The ibcstart.sh script only starts the new instance once the original one has exited: it’s inconceivable that Linux could somehow have not terminated the program but returned a success exit code to the script. So the original instance cannot be one of the conflicting instances. The restarted instance presumably is?one of the conflicting instances, though there is nothing in the log that obviously confirms this.
  8. This only seems to happen the first time IBC is run during a week.

?

After quite a bit of experimenting, I haven’t managed to work out a scenario that could adequately explain all this.

?

However I do think it must be the case that another instance has been mis-configured with the wrong API port number - you said at the start that you run multiple instances. Can you please double-check this.

?

?

?

?

From:?[email protected]?<[email protected]> On Behalf Of rik . via groups.io
Sent:?12 March 2025 08:28
To:?
[email protected]
Subject:?Re: [ibc] port already in use

?

screenshots included now

?


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?woensdag 12 maart 2025 8:16
Aan:?
[email protected]?<[email protected]>
Onderwerp:?FW: [ibc] port already in use

?

Hi Richard,

as mentioned yesterday I added some comments in my own logfile to see what happens after the restart.?

This morning I saw the same error message, and again twice the same instance : account -86 is open and normally reacting. The same account -86 is still (or again?) there, but the screen is grey and it does not respond to anything. You will find 2 screenshots, both with the grey screen. On the first my pointer is in the lower tab menu above the account -86, so the account number is shown. On the second, my pointer is above another account tab (7 tabs more to the left or to the right), showing the same account number. That's the best I could get to show you what I try to tell.

My code in the background stops checking after 22:00 and does not start before 8:45 in the morning. The auto-restart is just before midnight. I took the screenshot this morning around 8:30. So the code did not do anything, which is confirmed by my logfile. (the code runs "/opt/ibc/twsstart4080.sh" every 5' during the day, from 8:45 untill 22:00 : as far as I know this will open the 4080 instance if not open yet, or do nothing if already open, please correct me if I'm wrong).

If you can't think of any other reason, I will change the restart time and try to see what happens at that time.

?

Thanks anyway,

rik

?


Van:?rik dieltjens <rik_en_veronique1@...>
Verzonden:?dinsdag 11 maart 2025 16:18
Aan:?
[email protected]?<[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

Thanks for your reaction, Richard.

I have indeed running a code that is checking if some instance has been closed while it shouldn't. This also runs for many years now. I will add comment lines to my logfile to check if this code tries to start a new instance at some time where the ibc-log says that it is open already. Anyway, thanks for the tip.

best regards

rik


Van:?[email protected]?<[email protected]> namens Richard L King <rlking@...>
Verzonden:?dinsdag 11 maart 2025 10:51
Aan:?
[email protected]?<[email protected]>
Onderwerp:?Re: [ibc] port already in use

?

rik

?

As far as I can tell from the logfile, IBC is behaving fine. The restart does complete successfully, and then at 2025-03-11 08:40:09:452 the program shuts down: I presume this is because at this point you closed it manually, because it was displaying the ‘port already in use’ dialog?

?

All the evidence points to there really being another instance configured with the same API port. When the first instance closes for restart at 2025-03-10 23:49:02, it really has shut down – there is no possibility that it’s still running. And yet you say one instance (always the same) did not close as it should (it is still open, and does not react on anything)’. Can you get a screenshot showing this supposedly blocked instance, the new instance, and the error message together?

?

What seems most likely to me is that the original instance has indeed shut down and restarted successfully (which is what the log shows), and another new ?instance has somehow been started and it is this one that is showing the error dialog. I have no idea why that might have happened: perhaps you are doing periodic restarts using Task Scheduler to catch cases where IBC/TWS has crashed, and this just happens to be at the same time as the auto-restart?

?

So from my point of view I can’t see anything wrong here: there doesn’t appear to be an IBC problem. However I do note that you’re running a rather old version of IBC, and I would encourage you to move to the latest version.

?

Richard

?

?

From:?[email protected]?<[email protected]> On Behalf Of rik . via groups.io
Sent:?11 March 2025 08:03
To:?
[email protected]
Subject:?[ibc] port already in use

?

Hello,

I'm using ibc for years now, starting multipal instances on sunday or monday, and let them restart overnight until the weekend. Since a few weeks I'm getting the error "port already in use" (see printscreen) on the first restart moment, so I see it on monday or tuesday morning. This is because one instance (always the same) did not close as it should (it is still open, and does not react on anything). The new instance opens well but cannot use the API port as it seems to be still in use by the blocked instance. The only thing I can do is close everything but the blocked instance, restart my pc and start all over again. This happens only after the first overnight restart. The rest of the week everything ngoes fine (until now...).

I have no clue what or where to look for. The log is attached (this week I started on monday, so I saw the error this tuesday morning). Every help is welcome. Thanks,

rik