Search code examples
javarestlethttp-status-code-503http-status-code-504

Java Restlet gets 503/504 error, stops running


I have a Java program set up to make a request to a server every second, using Restlet, but every week during the same time they do some maintenance for about a minute within the hours that I'm running my program.

As a result, I get a couple of 504 errors and then a 503 error, and then for some reason my program stops running. It just doesn't continue after the 503 error. It says:

a recoverable error was detected (503), attempting again in 2000ms

but it doesn't attempt again. Since I've got it set up to keep requesting the server every second (which it stops doing once it hits the "recoverable error"), I would like to know if there's a way to make the program ignore the 504 and 503 errors and just continue on like nothing happened.


Solution

  • I understand your client program is developped using Restlet. You can setup the client resource to not retry on error by calling ClientResource#setRetryOnError(false), and catch exceptions, as said above.