[Progress Communities] [Progress OpenEdge ABL] Forum Post: Best way to catch a HTTP Timeout from the ClientBuilder

Status
Not open for further replies.
O

onnodehaan

Guest
Hi Guys I'm using the Clientbuilder for a while now. For speed I've set it up based on one of the examples online Now I'm wondering, if I where to change the example below and insert a timeout Example oResponse = ClientBuilder:Build():Client:Execute(oRequest). Would become oResponse = ClientBuilder:Build():Client:SetRequestTimeout(10):Execute(oRequest). What would be the best way to capture the timeout? Will the clientbuilder throw an error? Or will it return an error statuscode? Couldn't find this in the documentation, so I thought I'd just ask before logging a supprt case. REgards, Onno -------- UPDATE EXAMPLE ------ BLOCK-LEVEL ON ERROR UNDO, THROW. USING OpenEdge.Core.String. USING OpenEdge.Net.HTTP.ClientBuilder. USING OpenEdge.Net.HTTP.IHttpRequest. USING OpenEdge.Net.HTTP.IHttpResponse. USING OpenEdge.Net.HTTP.RequestBuilder. USING Progress.Json.ObjectModel.JsonObject. DEFINE VARIABLE httpUrl AS CHARACTER NO-UNDO. DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO. DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO. DEFINE VARIABLE oRequestBody AS String NO-UNDO. DEFINE VARIABLE oJsonEntity AS JsonObject NO-UNDO. DEFINE VARIABLE JsonString AS LONGCHAR NO-UNDO. SESSION:DEBUG-ALERT = TRUE. httpUrl = " www.googleapis.com/.../token". oRequestBody = new String('client_id=your_client_id&client_secret=your_client_secret&refresh_token=your_refresh_token&grant_type=refresh_token'). oRequest = RequestBuilder:post(" www.googleapis.com/.../token" , oRequestBody) :ContentType('application/x-www-form-urlencoded') :AcceptJson() :Request. oResponse = ClientBuilder:Build():Client:SetRequestTimeout(10):Execute(oRequest). MESSAGE oResponse:StatusCode SKIP oResponse:StatusReason SKIP VIEW-AS ALERT-BOX. oJsonEntity = CAST(oResponse:Entity, JsonObject). oJsonEntity:Write(JsonString, TRUE). MESSAGE STRING(JsonString) VIEW-AS ALERT-BOX.

Continue reading...
 
Status
Not open for further replies.
Top