I have met some 502 error and how can I make a client robust against 5XX errors by retrying the request once or twice if you receive one, that way even if they do occur, your software will continue running normally.
My codes are here http://pastebin.com/YHpZQ9Z9