Too Many Requests

Hi, our service works on mono(debian8x64).
When sending a request the server returns such response.
Please help, what could be the problem?

ServiceBase::Service Exception
Message: The remote server returned an error: (429) Too Many Requests.
Source: System
Target site: System.Net.WebResponse EndGetResponse(System.IAsyncResult)
Stack trace: at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) <0x404fe570 + 0x001ab> in :0
at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (IAsyncResult iar, System.Func2 endFunction, System.Action1 endAction, System.Threading.Tasks.Task1 promise, Boolean requiresSynchronization) <0x404fe120 + 0x00093> in :0

You’re likely hitting a load issue with Mono’s HTTP Stack.

Please note the future for running .NET and ServiceStack on Linux is to use .NET Core which is fast, stable and well-supported and ServiceStack just released support for in the latest release:

If you’re using ServiceStack on Mono I’d recommend upgrading when you can, which is significantly faster and more stable

Thanks, for a start I will try to update Mono.
Then plan the transition to .NET Core.

Which service do you call with HttpWebRequest? Is it your service or it’s some third-party service? Do you make this request from your ServiceStack service or just from a client? Need some more details about the place where this exception happen, but this could be possible due infinite loop in calling the service.

For example you make request to your /service1. In /service1 code makes HttpWebRequest to the same /service1 directly or indirectly through calling /service2 which calls /service1 again. In this case number of requests in System.Web requests queue will be exhausted and the error Too Many Requests will arise.

If service make a HttpWebRequest call to third-party service it may return Too Many Requests if you call it too often.

Function unloads data on the server.
Several portions on 7 MB are unloaded.
Data in the json format.
In functions no references to other services occur, only inquiries to a database.

Could you tell:

  • mono version, which you use.
  • web servers which you use to run ServiceStack services
  • show the full stack trace of exception, which is occured on your server. Before logging the exception on the server please set environment variable MONO_OPTIONS=--debug prior starting up server. For example, if you use xsp4, start it with MONO_OPTIONS=--debug xsp4 the same with fastcgi-mono-server4 or hyperfastcgi4.

MONO_OPTIONS=--debug fastcgi-mono-server ...
MONO_OPTIONS=--debug hyperfasctcgi4 ...

Mono - Mono JIT compiler version 4.6.1 (Stable Wed Oct 12 09:10:37 UTC 2016)
Nginx - nginx/1.6.2

could not configure trace :unamused:

The server returns this response:

504 Gateway Time-out

504 Gateway Time-out


I changed the server settings but didn’t help:

This is other error. Do you use fastcgi upstream or proxy? If you use fastcgi upstream then proxy settings will not apply to it. Nginx fastcgi options begin with fastcgi_ prefix, list of commands you can find here. But you need to check first that fastcgi server is working and check its logs. If you use fastcgi upstream, which fastcgi server do you use? If you use proxy what is the host endpoint? Is it self-hosted app or something else? Without exception stack trace from the server for first error it’s very difficult to understand where the exception is raised and what could be the cause of the exception.