HTTP Client ViaProxy Issue

Posted by chrisrichardson on 17-Mar-2016 07:51

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.
DEFINE VARIABLE httpUrl     AS CHARACTER        NO-UNDO.
 
httpUrl = "http://www.google.co.uk".
                           
oRequest = RequestBuilder:Get(httpUrl):Request.
 
oResponse = ClientBuilder:Build():ViaProxy('myproxy:8080'):Client:Execute(oRequest).

MESSAGE
    oResponse:StatusCode
    oResponse:StatusReason
    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)

All Replies

Posted by chrisrichardson on 17-Mar-2016 07:55

Ignore the <a> tags in the code.....the editor plugin has put them in.

Posted by Peter Judge on 17-Mar-2016 08:20

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):
        super(poClient).
    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(
                 ClientBuilder:Build():Client,
    URI:Parse('http://myproxy:8080')
                                     ).                        
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):
        super(poClient).
    end constructor.   
end class.
 
/* and in your session startup (ideally) */
ClientBuilder:Registry:Put(get-class(ISupportProxy):TypeName,
                           get-class(MyProxyClient)).
                          
And make your request calls as below.
 
Note that you will need to add the scheme ('http') to the proxy URI.
 
 

Posted by chrisrichardson on 17-Mar-2016 10:24

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 www.bbc.co.uk 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 URI........do 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 

Posted by Peter Judge on 17-Mar-2016 13:54

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).
 
 
 

Posted by chrisrichardson on 17-Mar-2016 14:59

Thanks for your help Peter.

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

Posted by cSocaciu on 06-Jul-2017 06:17

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.

Posted by chrisrichardson on 26-Jul-2017 11:34

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.

This thread is closed