When I run my program everyday, first I connect to ib.
Then I use this logic app.isConnected() to check if its connected using a python script.
I run it twice, because sometimes it does not connect on the first try.
Then I disconnect and run my actual trade script.
However, sometimes i get a connection error 504, sometimes it works. Any idea why its like this or how i should be altering it to run properly?