NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdf-java] Setting proxy host and port in matlab when using MexCDF

  • To: John Caron <caron@xxxxxxxxxxxxxxxx>
  • Subject: Re: [netcdf-java] Setting proxy host and port in matlab when using MexCDF
  • From: Favio Medrano <hmedrano@xxxxxxxxx>
  • Date: Thu, 30 Sep 2010 12:10:18 -0700
Sorry for taking this long to answer, I where working on some other
things, but I still have the problem, I cant connect to any outside
opendap url of working net using matlab and SNCTools. 

I get always this error when trying a nc_dump()
------------------------------------------------------------------------------
Sep 30, 2010 11:59:54 AM ucar.nc2.dods.DODSNetcdfFile <init>
INFO: DODSNetcdfFile
http://dods.mbari.org/opendap/data/oasis/netcdf/dailyAveragedM0.nc
java.net.ConnectException: Connection timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(Unknown Source)
        at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.SocksSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at java.net.Socket.<init>(Unknown Source)
        at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
        at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
        at
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
        at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
        at
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
        at opendap.dap.DConnect2.openConnection(DConnect2.java:212)
        at opendap.dap.DConnect2.getDDS(DConnect2.java:440)
        at opendap.dap.DConnect2.getDDS(DConnect2.java:420)
        at ucar.nc2.dods.DODSNetcdfFile.<init>(DODSNetcdfFile.java:202)
        at ucar.nc2.dods.DODSNetcdfFile.<init>(DODSNetcdfFile.java:170)
??? Error using ==> nc_info_java at 37
Could not open
'http://dods.mbari.org/opendap/data/oasis/netcdf/dailyAveragedM0.nc' as
either a local
file, a regular URL, or as a DODS URL.

Error in ==> nc_info at 57
                fileinfo = nc_info_java(ncfile);

Error in ==> nc_dump at 59
metadata = nc_info ( file_name );
---------------------------------------------------------------------------

( I tried with
http://dods.mbari.org/opendap/data/oasis/netcdf/dailyAveragedM0.nc just
for sample )


What I been trying to do is add credentials to the setproxy.m code, but
still not working 

function setproxy(proxyname, port)

 httpClient = org.apache.commons.httpclient.HttpClient();
 hostConf = httpClient.getHostConfiguration();
 hostConf.setProxy(proxyname, port);
 cred = org.apache.commons.httpclient.UsernamePasswordCredentials
('myusername','myproxypass') ;
 scope = org.apache.commons.httpclient.auth.AuthScope (proxyname,
port) ;

 httpClient.getState().setProxyCredentials(scope, cred ) ;  
 ucar.nc2.dataset.NetcdfDataset.setHttpClient(httpClient);


Still with no success, any other workaround for this, maybe i'm doing
something wrong in this piece of code.. 
I will surely appreciate! 

Regards

Favio M.

On Wed, 2010-09-08 at 18:09 -0600, John Caron wrote:
> Hi Favio:
> 
> Did this work? Im unclear if MexCDF is using netcdf-java, and if so,
> what version.
> 
> John
> 
> On 9/2/2010 2:36 PM, Brian Schlining wrote: 
> > I think this should work for you (this is matlab code I use
> > from http://nctoolbox.googlecode.com/hg/cdm/setproxy.m) 
> > 
> > 
> > httpClient = org.apache.commons.httpclient.HttpClient();
> > httpClient.getHostConfiguration().setProxy(proxyname, port);
> > ucar.nc2.dataset.NetcdfDataset.setHttpClient(httpClient);
> > 
> > On Thu, Sep 2, 2010 at 12:15, Favio Medrano <hmedrano@xxxxxxxxx>
> > wrote:
> >         Thanks for the reply.
> >         
> >         Yes Ethan I already tried setting those properties in the
> >         code, those
> >         exact two lines that you suggest:
> >         
> >         
> > System.setProperty('http.proxyHost','http://hmedrano:myspass@proxy.server');
> >         System.setProperty('http.proxyPort','3128');
> >         
> >          but still with no success, I'm using the SNCTools for
> >         matlab, and i put
> >         this code inside the nc_info_java.m,
> >         maybe I'm not setting this properties in the right place.
> >         
> >         Regards
> >         FavioM
> >         
> >         On Wed, 2010-09-01 at 15:01 -0600, Ethan Davis wrote:
> >         > Hi Favio,
> >         >
> >         > The code quoted below is already in the netCDF-Java
> >         library. All you
> >         > should have to do is set the Java system properties that
> >         the code quoted
> >         > below is using, i.e., "http.proxyHost" and
> >         "http.proxyPort".
> >         >
> >         > Try adding the following to your code:
> >         >
> >         > System.setProperty( "http.proxyHost",
> >         "<yourHttpProxyHost>");
> >         > System.setProperty( "http.proxyPort", "<your
> >         HttpProxyPort>");
> >         >
> >         > replacing the angle bracketed text with the appropriate
> >         host and port
> >         > information for your proxy.
> >         >
> >         > I'm not that familiar with Matlab so others may be able to
> >         chime in with
> >         > other suggestions.
> >         >
> >         > Hope that helps,
> >         >
> >         > Ethan
> >         >
> >         > On 8/30/2010 1:29 PM, Favio Medrano wrote:
> >         > > Hello all
> >         > >
> >         > > I have a problem working with my opendap server, when
> >         working inside the
> >         > > proxy server, it simply doesnt work, I read already the
> >         thread:
> >         > >
> >         > > Re: setting proxy host and port in matlab/java
> >         > > That discusses this:
> >         > >
> >         > >> Hi all:
> >         > >>
> >         > >> According to nick.bower@xxxxxxxxxxxxxxxxxxxxx, setting
> >         the following
> >         > >> System properties (eg on the java command line) will
> >         allow a proxy to
> >         > >> work:
> >         > >>
> >         > >> String proxyHost =
> >         System.getProperty("http.proxyHost");
> >         > >> String proxyPort =
> >         System.getProperty("http.proxyPort");
> >         > >> if ((proxyHost != null) && (proxyPort != null)) {
> >         > >> _client.getHostConfiguration().setProxy(proxyHost,
> >         > >> Integer.parseInt(proxyPort));
> >         > >>
> >         > >> the above lines of code are in
> >         ucar.nc2.util.net.HttpClientManager
> >         > >> which
> >         > >> is our interface to org.apache.commons.httpclient, used
> >         by the
> >         > >> DConnect2
> >         > >> opendap client.
> >         > >>
> >         > >> I havent made this work myself, although nick said it
> >         worked for him.
> >         > >> Since you are having trouble with those settings, I am
> >         cc'ing him in
> >         > >> case he can help.
> >         > >>
> >         > >
> >         > > My question is, where can i put this commands in order
> >         to make my
> >         > > proxyhost to work with the snctools?
> >         > >
> >         > > I tried putting this commands in the file nc_info_java.m
> >         of the snctools
> >         > > with my proxy host and port, but still it didn't work.
> >         > >
> >         > > this is the error that i get:
> >         > >
> >         > > ??? Error using ==> nc_info_java at 36
> >         > > Could not open
> >         > >
> >         
> > 'http://my.server.mx:8080/thredds/dodsC/opanatl3_full/opanatl3_full__1965--2006'
> >  as
> >         > > either a local file, a regular URL, or as a DODS URL.
> >         > >
> >         > > Any work arounds for this, i would really apreciate it!.
> >         > >
> >         > > Thank you!
> >         > > FavioM
> >         > >
> >         > >
> >         > > _______________________________________________
> >         > > netcdf-java mailing list
> >         > > netcdf-java@xxxxxxxxxxxxxxxx
> >         > > For list information or to unsubscribe, visit:
> >         http://www.unidata.ucar.edu/mailing_lists/
> >         >
> >         > _______________________________________________
> >         > netcdf-java mailing list
> >         > netcdf-java@xxxxxxxxxxxxxxxx
> >         > For list information or to unsubscribe, visit:
> >         http://www.unidata.ucar.edu/mailing_lists/
> >         
> >         
> >         _______________________________________________
> >         netcdf-java mailing list
> >         netcdf-java@xxxxxxxxxxxxxxxx
> >         For list information or to unsubscribe, visit:
> >         http://www.unidata.ucar.edu/mailing_lists/
> > 
> > 
> > 
> > -- 
> > ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 
> > Brian Schlining
> > bschlining@xxxxxxxxx
> > 
> > 
> > _______________________________________________
> > netcdf-java mailing list
> > netcdf-java@xxxxxxxxxxxxxxxx
> > For list information or to unsubscribe, visit: 
> > http://www.unidata.ucar.edu/mailing_lists/ 
> 
> _______________________________________________
> netcdf-java mailing list
> netcdf-java@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit: 
> http://www.unidata.ucar.edu/mailing_lists/ 




  • 2010 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: