API Time-out

From Haasonline Software Wiki
Jump to: navigation, search

Haasbot works based on its own framework. This framework and the stability of it is checked daily using automated unit tests, and this way we are sure it works as it should be. However, the underlaying API drivers are most of the times the cause of instability and therefore they have their own error handling system.

These handling systems are located within the drivers itself as they are developed and controlled by the Haasonline Software Team. We set the rules of whats acceptable or not. Of course, this is not as easy as it appears and therefore we have described the situations that may happen and how we handle it within the driver models.

Communication rules/limits

Execution time measurements

If we measure a response time of greater then 1 minute for more then 6times in a hour -> 5min timeout

If we measure a response time of greater then 30seconds for more then 24times -> 5min timeout

If we measure an average response time of greater then 90seconds -> 5minute timeout


We measure (and reset) this during the peak times each hour. When a timeout occurs, then we know an exchange’s API is unstable, so we "reset" the counter to half and we will retry everything after the timeout is completed.

HTML error handling

  • HTML-403 (access denied) -> 5 minute timeout (likely we are rated at DDOS attacker)
  • HTML-522 (cloudflare) -> 2minute timeout (cloudflare is protecting now)
  • HTML-1010 (cloudflare) -> Total block, software is banned at cloudflare
  • HTML-1006,1007,1008 (cloudflare) -> Total block, user IP is banned, issue big error

Connectivity handling

DNS Errors -> small timeout to give the DNS a little room

Exchange error handling

  • Invalid key found -> Give warning and disconnect.
  • Nonce -> do reconnect protocol
  • Limit orders disabled -> Give warning only
  • Market orders disabled -> Give warning only
  • Trade-amount too low on orders -> Give warning only
  • Trade-amount too high on order -> Give warning only