How to handle RestClient :: ServerBrokeConnection

I use the latest gem rest-client version and with external access I see many RestClient :: ServerBrokeConnection errors, how do I handle this?

Next challenge fails

response = RestClient::Request.execute(method: :post, url: url, headers: headers, "Content-Type" => "application/x-www-form-urlencoded") 
+5
source share
1 answer

This error occurs when the server breaks the connection to the client. You can decide to repeat the request or simply issue an error so that the user can find out about it and process it.

Because, as the rest-client handles broken connections, as shown here , all you can do is save from it

 begin response = RestClient::Request.execute(method: :post, url: url, headers: headers, "Content-Type" => "application/x-www-form-urlencoded") rescue RestClient::ServerBrokeConnection // retry or do something end 
+5
source

Source: https://habr.com/ru/post/1208552/


All Articles