0 votes
by (150 points)
edited by

Hi,

To workaround the issue mentioned in below link, I decided to use Rebex when proxy is not HTTPS. UseRebex property will be set to "True" when client specified no proxy or HTTP proxy. If HTTPS proxy is specified, I do not use Rebex, but rather make plain WebRequest. When I am trying this, I am getting "System.Net.WebException: Error while processing request.
--> Rebex.Net.IB: Error while processing request." when I assiged HTTP proxy details. Could you please let me know if I am missing something?

http://forum.rebex.net/7566/httprequestcreator-argumentexception-assigned-contains

public partial class ConfigurationService : System.Web.Services.Protocols.SoapHttpClientProtocol
{
    public bool UseRebex { get; set; }

    public Rebex.Net.Proxy RebexProxy { get; set; }

    public System.Net.IWebProxy DefaultProxy { get; set; }

    protected override System.Net.WebRequest GetWebRequest(Uri uri)
    {
        Debug.WriteLine("Configuration Service");

        System.Net.WebRequest request = null;

        Debug.WriteLine("Use Rebex: " + UseRebex.ToString());

        if (UseRebex)
        {
            HttpRequestCreator _httpRequestCreator = new HttpRequestCreator();
            _httpRequestCreator.Settings.SslAllowedVersions = TlsVersion.TLS12;
            _httpRequestCreator.ValidatingCertificate += CustomCertificateVerifier.CustomCertificateValidator;
            if (RebexProxy != null)
                _httpRequestCreator.Proxy = RebexProxy;
            request = _httpRequestCreator.Create(uri);

            request.PreAuthenticate = true;
            request.Credentials = new NetworkCredential("username", "password");
        }
        else
        {
            request = base.GetWebRequest(uri);

            if(DefaultProxy != null)
                request.Proxy = DefaultProxy;

            request.PreAuthenticate = true;
            request.Credentials = this.Credentials;
        }

        return request;
    }
}
by (150 points)
Just to be clear, below is step how I initialized RebexProxy.

 Uri _uri = new Uri(_configDS.InetProxy);
                    _rebexProxy = new Rebex.Net.Proxy();

                    _rebexProxy.ProxyType = ProxyType.HttpConnect;
                    _rebexProxy.Host = _uri.Host;
                    _rebexProxy.Port = _uri.Port;
                    _rebexProxy.Credentials = nc;
                    _rebexProxy.BypassProxyOnLocal = false;

1 Answer

0 votes
by (147k points)
The "Error while processing request" error is just a wrapper exception. The exception that caused the operation to fail is contained in its InnerException chain. To make it possible to tell what is going on, please either capture a full .ToString() representation of the "Error while processing request" exception, or create a log using HttpRequestCreator's LogWriter property (as described at https://www.rebex.net/kb/logging/) and post the relevant part here. Thanks!
by (150 points)
Thanks Lukas, It is issue on my end with the way i setup proxy, and it is working fine now.

As I mentioned above, we are relying on Rebex DLL when customer specified no proxy or HTTP proxy.  If HTTPS proxy is specified, we go with out routine approach.  Would you mind reviewing below code once?

public partial class ConfigurationService : System.Web.Services.Protocols.SoapHttpClientProtocol
    {
        /// <summary>
        /// If dock is assigned with no proxy or HTTP proxy to communicate, use Rebex DLLs.
        /// If dock is assigned with HTTPS proxy, make default WebRequest.
        /// </summary>
        public bool UseRebex { get; set; }

        //Proxy information when Rebex DLLs are being used.
        public Rebex.Net.Proxy RebexProxy { get; set; }

        /// <summary>
        /// Overides base GetWebRequest method
        /// If dock has no proxy or HTTP proxy, Rebex approach will be used.
        /// If dock has HTTPS proxy, routine webrequest will be placed.
        /// </summary>
        protected override System.Net.WebRequest GetWebRequest(Uri uri)
        {
            System.Net.WebRequest request = null;

            if (UseRebex)
            {
                //Create HTTP request creator to allow only TLS1.2
                HttpRequestCreator _httpRequestCreator = new HttpRequestCreator();
                _httpRequestCreator.Settings.SslAllowedVersions = TlsVersion.TLS12;
                _httpRequestCreator.ValidatingCertificate += CustomCertificateVerifier.CustomCertificateValidator;

                //If HTTP proxy is being used, assign proxy info
                if (RebexProxy != null)
                    _httpRequestCreator.Proxy = RebexProxy;

                request = _httpRequestCreator.Create(uri);

                //Preauthenticate and Credentials needs to be set for Rebex "HttpRequest"
                request.PreAuthenticate = true;
                request.Credentials = this.Credentials;
            }
            else
            {
                //In case of Non-Rebex approach, continue with base class behavior.
                request = base.GetWebRequest(uri);
            }

            return request;
        }
    }
by (147k points)
The code seems alright.

Once we add support for classic HTTP/HTTPS proxies (this is currently planned for one of the next releases - we will let you know), the non-Rebex branch could be disabled.
by (150 points)
Thanks Lukas!
...