Desktop productivity for business analysts and programmers

Error: Connection Refused with PROC HTTP and PROXYHOST

Reply
Occasional Contributor
Posts: 13

Error: Connection Refused with PROC HTTP and PROXYHOST

[ Edited ]

Hello,

 

I am stuck in this code for a day and thus far, have been unable to find a solution. My massive companies massive IT and BI teams have been unhelpful. 

 

So I am coming to the community of experts to see if I should just drop the ball and find alternate solution to this.

 

I am not super SAS Smart so please bear with me if I misinterpret something.

 

MIssion: I am trying to connect to either of the 2 links below to get Monthly Data pull for Fed Fund Rate, which would then be used in a much grander SAS Project (Already Developed) as a Multiplier.

 

Here are my links:

 

1.  http://www.federalreserve.gov/datadownload/Output.aspx?rel=H15&series=d7e27b7b09a3a7feae95b9c61781fc...

 

2. https://fred.stlouisfed.org/series/FEDFUNDS/downloaddata/FEDFUNDS.csv

 

EDIT: Using SAS 9.3 on Linux Server with SAS EG5.1

 

 

Here is my code:

filename in "/server/rahul/Test/in";
filename out "/server/rahul//Test/out.csv";

data _null_;
file in;
input;
put _infile_;
datalines;
;
proc http
out=out
url="https://fred.stlouisfed.org/series/FEDFUNDS/downloaddata/FEDFUNDS.csv"
method="post" proxyhost="xx.xx.xx.x" proxyport=xxxx; run;

When I run this code as is, I get the following error message:

 

ERROR: java.net.ConnectException: Connection refused

 

However, if I remove the "S" from "HTTPS://", I do not get any error message and it generates an output (out.csv) with the following Text within:

 

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://fred.stlouisfed.org/series/FEDFUNDS/downloaddata/FEDFUNDS.csv">here</a>.</p>
</body></html>

I have pinged the PROXY with and without Port and it pings fine. Networking is saying that my current SAS (9.3) PROD Server has a connection and firewall exception to connect to the Proxy, however, when I run the "https" code, there is no LOG on the Proxy showing it was hit by SAS PROD Server.

 

Any help would be beneficial. I have googled and tried every single approach mentioned, to no avail.

 

Thanks,

 

RV

 

Note: Same/similar code was posted in the community by a prior ex-consultant, with no solution. This is with more details related to the errors.

Super Contributor
Posts: 467

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

Did you try using the filename method:

 

Filename want "your path";
Filename data_web url "https://fred.stlouisfed.org/series/FEDFUNDS/downloaddata/FEDFUNDS.csv";

data _null_;
infile data_web;
file want ;
input ;
put _infile_;
;
run;
Thanks,
Suryakiran
Occasional Contributor
Posts: 13

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

[ Edited ]
Posted in reply to SuryaKiran

Hi Surya,

 

Thanks for the response. Yes I have. 

 

I get a simple: ERROR: Connection refused.

 

That is why we have a Proxy.

 

Even tried with Proxy: Suffix to filename. Same error.

Super Contributor
Posts: 467

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

Check if this helps: http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003286920.htm

Also @ChrisHemedinger has several tips on PROC HTTP here

Thanks,
Suryakiran
Occasional Contributor
Posts: 13

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

Posted in reply to SuryaKiran

Surya, 

Thanks @ChrisHemedinger has done a great job with setting up that resource. I found that this morning and have tried many itteration from their to make my situation work, but no luck. 

 

Still, have bookmarked it for future quick access.

 

I have our SAS team looking at Link One of embedding the Certificate information in the JRE on the server side, and will update. 

 

Regular Contributor
Posts: 150

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

I got this working in C# using the following code. No proxy was used. Hopefully, this will help you find the issue:


        private static void GetRestData()
        {
            string url = "https://www.federalreserve.gov/datadownload/Output.aspx";
            string parms =
                "?rel=H15&series=d7e27b7b09a3a7feae95b9c61781fcd8&lastobs=12&from=&to=&filetype=csv&label=include&layout=seriescolumn&type=csv";
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri(url);

            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            // List data response.
            HttpResponseMessage response = client.GetAsync(parms).Result;  // Blocking call!
            if (response.IsSuccessStatusCode)
            {
                // Parse the response body. Blocking!
                var json = response.Content.ReadAsStringAsync().Result;
                Console.WriteLine($"{json}");
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }

Trusted Advisor
Posts: 1,711

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

Hi there,

i think it would be a good idea to add tge server ssl certificates (of the url) to your sas java private runtime certificate store (with SAS deployment manager). You can ask your SAS admin to do it for you.

Once done, try again with https.
Occasional Contributor
Posts: 13

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

Posted in reply to JuanS_OCS
Juan, I think that is the issue right now. Talked with Networking as http link does hit the Porxy Server, and yields no results, cause well, everything now is https.

However, https does not. I passed on the information Surya posted and I had found earlier to my SAS Admin team and they are looking in to this. I will update this post if that fixes it.
Super User
Posts: 10,615

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

Or using the third side software like CURL .

Occasional Contributor
Posts: 13

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

Thanks Ksharp. Will look in to it, but there are major communication breaks between our IT/Networking/SAS Admin team, that i see this being the solution. Still worth checking it out. Thanks.

Community Manager
Posts: 3,355

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

[ Edited ]

On Linux, you definitely need those SSL certificates set up.

 

@AlanC's C# example works on Windows -- seemingly without proxy setup -- because .NET uses the Windows HTTP Client connection and SSL support/proxy routing is handled (usually) through that.

 

@Ksharp suggestion for trying cURL is useful -- but cURL on Linux will have the same requirements for SSL (https) access.  You need the SSL certs.

 

You could try...for fun...via SAS University Edition.  The latest version does have SSL support.  But I don't know how it will work in your proxy setup.  That might be a good proof of concept to help you over the hump and allows you to articulate what you need from your IT folks in a production environment.

Occasional Contributor
Posts: 13

Re: Error: Connection Refused with PROC HTTP and PROXYHOST

Posted in reply to ChrisHemedinger

@ChrisHemedinger You are a genius. One thing I was able to verify is that the Proxy is working the way it should by using SAS University Edition. 

 

I was able to run the following code with no problem and got the output as required and in the format desired.

 

filename out "/folders/myfolders/out.csv";

proc http   
   	out=out 
  	url="http://www.federalreserve.gov/datadownload/Output.aspx?rel=H15&series=d7e27b7b09a3a7feae95b9c61781fcd8&lastobs=12&from=&to=&filetype=csv&label=include&layout=seriescolumn&type=csv" 
 	method="get"	
 	proxyhost="xx.xx.xx.x"
 	proxyusername= 'patelr'
 	proxypassword= 'xxxxxxxxxxxxx'
	proxyport=xx;

run;

So the proxy works and the code works. It is just the Linux SAS Server is not liking the HTTPS on the Server itself and not even hitting the Proxy. 

 

Our BI (SAS) team has a track open with SAS to figure this out.

 

Will update.

Ask a Question
Discussion stats
  • 11 replies
  • 269 views
  • 7 likes
  • 6 in conversation