hitbtc-com / hitbtc-api

HitBTC API
GNU Lesser General Public License v3.0
323 stars 153 forks source link

Rate limit (429 - Too Many Requests) calculation is buggy! #156

Open ErrorEater opened 6 years ago

ErrorEater commented 6 years ago

The new rate limit is: 100 requests/second per IP. Unfortunately there is bug in this calculation. If you try to send 2 simultaneous requests you immediately receive the rate limit error. If you send the requests one after another you don't hit any rate limit error. This rate limit calculation is buggy. Please fix it.

C# code to reproduce the error:

using System;
using System.Net;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            try
            {
                //RunSerial();
                RunParallel();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.WriteLine("Press a key to exit.");
            Console.ReadKey();
        }

        private static void RunSerial()
        {
            new WebClient().DownloadString(new Uri("https://api.hitbtc.com/api/2/public/currency"));
            new WebClient().DownloadString(new Uri("https://api.hitbtc.com/api/2/public/symbol"));
        }

        private static void RunParallel()
        {
            Task.WaitAll(new WebClient().DownloadStringTaskAsync(new Uri("https://api.hitbtc.com/api/2/public/currency")),
                         new WebClient().DownloadStringTaskAsync(new Uri("https://api.hitbtc.com/api/2/public/symbol")));
        }
    }
}
hitbtc-com commented 5 years ago

@aliveli186 , this issue has already been fixed. Please check it and tell us if the problem still exists