HTTP Client ViaProxy Issue - Forum - OpenEdge Development - Progress Community

HTTP Client ViaProxy Issue

  • OE 11.5.1

    I'm struggling to put the syntax together in order to make an HTTP request from behind our proxy server.  Internal requests are fine, but when adding the ViaProxy option I get the errors below.

    I'm missing something in the construction of the code, but can't figure our what.  Any help/advice please?

    USING OpenEdge.Net.HTTP.IHttpRequest.
    USING OpenEdge.Net.HTTP.IHttpResponse.
    USING OpenEdge.Net.HTTP.RequestBuilder.
    USING OpenEdge.Net.HTTP.ClientBuilder.
    DEFINE VARIABLE oRequest    AS IhttpRequest     NO-UNDO.
    DEFINE VARIABLE oResponse   AS IhttpResponse    NO-UNDO.
    httpUrl = "".
    oRequest = RequestBuilder:Get(httpUrl):Request.
    oResponse = ClientBuilder:Build():ViaProxy('myproxy:8080'):Client:Execute(oRequest).
        view-as alert-box info.

     The error message:

    Lead attributes in a chained-attribute expression (a:b:c) must be type HANDLE or
    a user-defined type and valid (not UNKNOWN). (10068)
    DYNAMIC-NEW cannot instantiate class OpenEdge.Net.HTTP.ProxyHttpClient because
    the wrong number of parameters were passed to the constructor, or the constructor was not PUBLIC. (14758)
  • Ignore the <a> tags in the code.....the editor plugin has put them in.

  • That's a bug in 11.5 that's fixed in 11.6. The ProxyHttpClient is missing a constructor. If you add it  things should behave themselves a little better.
        constructor public ProxyHttpClient(input poClient as IHttpClient):
        end constructor.
    If you don't want to muck about with the shipped source, then you have a few options
    1) Proxy the request instead of the client. There's a ViaProxy() method on the RequestBuilder too.
    2)  The ClientBuilder uses a decorator to add proxy capabilities. You can decorate it yourself.
    def var oClient as IHttpClient no-undo.
    oClient = new OpenEdge.Net.HTTP.ProxyHttpClient(
    oResp = oClient:Execute(oRequest).
    3)  Create a type that does have that constructor, and have the ClientBuilder use it
    class MyProxyClient inherits OpenEdge.Net.HTTP.ProxyHttpClient:
               constructor public MyProxyClient(input poClient as IHttpClient):
        end constructor.   
    end class.
    /* and in your session startup (ideally) */
    And make your request calls as below.
    Note that you will need to add the scheme ('http') to the proxy URI.
  • Thanks for the detailed info Peter  I'm still playing with this and getting the error after waiting a few seconds (maybe 30)  for the request to complete:

    Connection failure for host port 80 transport TCP. 

    oRequest = RequestBuilder:Get(httpUrl):ViaProxy('http://myproxy:8080'):Request.
    oResponse = ClientBuilder:Build():Client:Execute(oRequest).

    You mentioned adding the scheme ('http') to the proxy I need to add something else here?

    Finally - where would I add the missing constructor if I was to update the OE code?

    I know the proxy server is accepting requests as I've tested with wget -e http_proxy=myproxy:8080 

  • There's a bug in 11.5 (issue PSC00339077 ; fixed in 11.6) where we connect to the wrong host – to the request target, not the proxy – for all requests.
    You would have to ask Tech Support for a hotfix or patch it yourself (I can give you instructions for that). Hotfix would be nice since we'd probably fix both issues at once (the constructor and the wrong host).
  • Thanks for your help Peter.

    I'll go the hotfix route and let you know how it goes.

  • Hello,

    Anyone can detail the steps needed to patch the OpenEdge 11.5.1 in order to have the "ViaProxy()" method working and also the problem with the wrong host?

    Thanks and regards,

    Claudiu S.

  • Hi Claudiu, we reverted back to 4gl sockets and a mixture of wget/curl via os-command.  Also some .net implementations that acted as a wrapper around a 3rd party web service. We ended up going down this route as we had issues with SSL certs on TLS 1.1/1.2.

    You're best bet is to get the hot-fix, or upgrade to 11.7 if possible.