I've the following code that I've extract from ovh-rest gem:
method = :get
@api_url = "https://api.ovh.com/1.0"
@api_key, @api_secret, @consumer_key = "123456789", "abcdef", "ghijkl"
endpoint = "/ip/123.456.678/"
url = @api_url + endpoint
uri = URI.parse(url)
body = nil
ts = Time.now.to_i.to_s
sig = "$1$" + Digest::SHA1.hexdigest("#{@api_secret}+#{@consumer_key}+#{method.upcase}+#{url}+#{body}+#{ts}")
request_uri = uri.path
request_uri += '?' + uri.query if uri.query
request = Net::HTTP.const_get(method.capitalize).new(request_uri)
request["X-Ovh-Application"] = @api_key
request["X-Ovh-Consumer"] = @consumer_key
request["X-Ovh-Timestamp"] = ts
request["X-Ovh-Signature"] = sig
request["Content-type"] = "application/json"
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
response = http.request(request)
JSON.parse(response.body)
If I do everything step by step I've the following error:
{
"errorCode": "QUERY_TIME_OUT",
"httpCode": "400 Bad Request",
"message": "Query out of time"
}
But if I wait some seconds (variable duration) before doing response = http.request(request)
, I've a successful request:
{
"organisationId": "nil",
"country": "myCountry",
"routedTo": {
"serviceName": "somename"
},
"ip": "123.456.678/32",
"canBeTerminated": true,
"type": "failover",
"description": "nil"
}
I don't know if the problem comes from my server (ruby process to high for quick response) or if it's coming from somewhere else around..
Important note :
This code was working like a charm but some days ago.. Stop working.
This was solved by a date resynchro. Since all servers' hours are the same, it works like a charm.