Can please anyone help me fixing this problem. I keep getting timeout errors intermittently for kite.place_order( .. function requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=15)
So far I tried, increased time out from 7 to 15 Closing connections post use in code Created inbound and outbound rules in firewall to allow traffic over port 443. Changed VM location from Central India to Asia Pacific to US but nothing works. I am using VM on Windows Azure running Win 11 Pro and Python is used for coding.
Still doesnt resolve. Any ideas what is causing this that too intermittently. BTW it used work smoothly few days back.
thats already done as well . seems to find the problem. pool = { "pool_connections": 10, "pool_maxsize": 10, "max_retries": 3, "pool_block": True } kite = KiteConnect(api_key=api_key,pool=pool, timeout=15) kite.set_access_token(token_key)
api.kite.trade is always at 104.16.4.81? If so I can set a rule in my firewall to have unrestricted traffic from this IP. That should work right unless IPs are not dynamic at your end for api
@sujith, to make sure any firewal issues I wrote few lines which places AMO order and cancels it. Sorry for spam on your system but I ran few order placement and cancellations in loop with some wait time and results : Not a single order failed : See below. So why only market hours I face this problem with regular variety orders. This tells me all is well my side.
Placing order : Time taken: 1.0781595706939697 seconds Placing order : Time taken: 1.079775333404541 seconds Placing order : Time taken: 1.053192377090454 seconds Placing order : Time taken: 1.0728495121002197 seconds Placing order : Time taken: 1.0603604316711426 seconds Placing order : Time taken: 1.052431583404541 seconds Placing order : Time taken: 1.0909044742584229 seconds Placing order : Time taken: 1.0376999378204346 seconds Placing order : Time taken: 1.02510404586792 seconds Placing order : Time taken: 1.033116102218628 seconds Placing order : Time taken: 1.087824821472168 seconds Placing order : Time taken: 1.0271646976470947 seconds
so I use this kite object to place order buy and sell. first time it works. and I use the same kite object for other order placement, since I run in while loop that checks if there is new buy or sell signal it places order using same kite object instance without creating fresh. this is the time where I think its failing. What might be causing this time out behaviour in this scenario?
Did you try without assigning custom pool? Difficult to pin point where this issue is arising from. Could be firewall or change cloud provider and check.
I know it may not be wise design but I am running out of ideas here. so do you think every time I transact with api I do following will be any problem :
kite = KiteConnect(api_key=api_key) do my trans : i.e, place buy order, trailling order ,sell order, modify or cancel order, get margin etc..
If I get my transactions done E2E in 1 or 2 sec I can probably live with it. Is this ok to make those many frequent calls. Because what I notice is 1st time when kite object is created it happens in less than sec. problem starts when I keep reusing the same kite object in my code
so I use this kite object to place order buy and sell. first time it works, and I use the same kite object for other order placement .... this is the time where I think its failing.
Can you check if you are exceeding the maximum connection? Maybe increase the pool_connections, pool_maxsize and set pool_block to false and check once.
pool = {
"pool_connections": 10,
"pool_maxsize": 10,
"max_retries": 3,
"pool_block": True
}
kite = KiteConnect(api_key=api_key,pool=pool, timeout=15)
kite.set_access_token(token_key)
api.kite.trade is always at 104.16.4.81? If so I can set a rule in my firewall to have unrestricted traffic from this IP. That should work right unless IPs are not dynamic at your end for api
Placing order :
Time taken: 1.0781595706939697 seconds
Placing order :
Time taken: 1.079775333404541 seconds
Placing order :
Time taken: 1.053192377090454 seconds
Placing order :
Time taken: 1.0728495121002197 seconds
Placing order :
Time taken: 1.0603604316711426 seconds
Placing order :
Time taken: 1.052431583404541 seconds
Placing order :
Time taken: 1.0909044742584229 seconds
Placing order :
Time taken: 1.0376999378204346 seconds
Placing order :
Time taken: 1.02510404586792 seconds
Placing order :
Time taken: 1.033116102218628 seconds
Placing order :
Time taken: 1.087824821472168 seconds
Placing order :
Time taken: 1.0271646976470947 seconds
kite = KiteConnect(api_key=api_key) #,pool=pool, timeout=15)
kite.set_access_token(token_key)
# ClientMgmt.UpdateClientBalance(kite,client.ClientID)
return kite
so I use this kite object to place order buy and sell. first time it works. and I use the same kite object for other order placement, since I run in while loop that checks if there is new buy or sell signal it places order using same kite object instance without creating fresh. this is the time where I think its failing. What might be causing this time out behaviour in this scenario?
some pointers will help Please
kite = KiteConnect(api_key=api_key)
do my trans : i.e, place buy order, trailling order ,sell order, modify or cancel order, get margin etc..
If I get my transactions done E2E in 1 or 2 sec I can probably live with it. Is this ok to make those many frequent calls. Because what I notice is 1st time when kite object is created it happens in less than sec. problem starts when I keep reusing the same kite object in my code
pool_connections, pool_maxsize
and setpool_block
to false and check once.