Url connections

When I try to open a connection calling the CONNECTION method of the URlConnection class, it doesn't work and stucks until trhowing a TimeOut Exception. It doesn't matter which URL I try to connect to, it never works. I get an URlConnection object by invoking the "openConnection" method of an URL object. Can someone suggest me a solution?
Thanks.
Fabio

My internet connection works properly, even though it has some limitations, since I have to pass through my company firewall for accessing internet sites. For example, I cannot open Ftp connections with external Ftp servers.
I think that connections to external sites should be treated in the same way, even if they're made by the browser or bye Java applications. Am I right or not? And could you suggest me a way to check it, please?
Thank you anyway ofr your suggestion.
Fabio

Similar Messages

  • Close URL Connection netstat

    hello all,
    I hope you can help me.
    Please have a look at my code below
    I open an URL Connection but I can't close it.
    If i type in a DOS Box netstat I see a lot of connection.
    Now my question is how can I close the connection.
    m_http.disconnect() seems not to work.
    public class Unbenannt1 extends Applet
      Button button1 = new Button();
      private HttpURLConnection m_http = null;
      private URL m_MyAlarmURL = null;
      private URLConnection m_MyURLConnection = null;
      private long m_TimeAlarmXML = 0;
      private boolean m_TimeUpdate = true;
      /**Das Applet initialisieren*/
      public void init()
        String a_str = "http://"+ getCodeBase().getHost() + "/x.xml";
        try
          m_MyAlarmURL = new URL( a_str );
        catch ( MalformedURLException ie )
        try
          jbInit();
        catch(Exception e)
          e.printStackTrace();
      /**Initialisierung der Komponenten*/
      private void jbInit() throws Exception
        button1.setLabel("button1");
        button1.setBounds(new Rectangle(27, 28, 78, 27));
        button1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            button1_actionPerformed(e);
        setLayout(null);
        setBackground(java.awt.Color.lightGray);
        setSize(426,266);
        this.add(button1, null);
      void button1_actionPerformed(ActionEvent e)
        int a_int = 0;
        try
            m_MyURLConnection = m_MyAlarmURL.openConnection();
            m_http = (HttpURLConnection)m_MyURLConnection;
            m_http.setRequestMethod( "HEAD" );
            m_http.setUseCaches(false);
            m_http.connect();
            a_int = m_http.getResponseCode();
            m_http.disconnect();
            m_http = null;
            m_MyURLConnection = null;
            System.gc();
          catch ( java.io.IOException ioe  )
            a_int = 404;
    }Thanks a lot
    Prediger

    Usually those connections linger around for some time, and will then be closed by the OS once a certain timeout has been reached. I don't know how to change that timeout, though.
    Btw: the docs don't claim that the connection will be closed. The description for disconnect() is "Indicates that other requests to the server are unlikely in the near future"
    If you still see the connection after a while, then something is wrong, but I've seen connections like that hang around for several minutes even after the JVM was terminated.
    Thomas

  • Map Viewer URL Connection Issue

    Hi,
    I have an UI project, for which i have created a Deployment Profile named 'adfXXXXXUI' nothing but created a adflibrary for that UI project.
    While creating the adf jar, i have come across an Option called 'Connections' .
    Here i have selected Connection Names Only ... means i will be getting all the names of the connections i have created & those will be reflected in my local connection.xml file.
    After configuring the rest of the params, i deployed my UI project to "deploy -> adfXXXXXUI.jar".
    And we have used this jar to integrate with another UI application ... And the taskflows avilable in the jar will be used in the other UI application.
    Now here is my problem ... Actually my connections.xml file has a URL Connection. This is how it looks like....
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <References xmlns="http://xmlns.oracle.com/adf/jndi">
    <Reference name="MapServer" className="oracle.adf.model.connection.url.HttpURLConnection" xmlns="">
    <Factory className="oracle.adf.model.connection.url.URLConnectionFactory"/>
    <RefAddresses>
    <XmlRefAddr addrType="MapServer">
    <Contents>
    <urlconnection name="MapServer" url="http://sbsys1.intra.schneider.com:8109/mapviewer"/>
    </Contents>
    </XmlRefAddr>
    </RefAddresses>
    </Reference><Reference name="snibuilddb" className="oracle.jdeveloper.db.adapter.DatabaseProvider" credentialStoreKey="snibuilddb" xmlns="">
    <Factory className="oracle.jdeveloper.db.adapter.DatabaseProviderFactory"/>
    <RefAddresses>
    <StringRefAddr addrType="subtype">
    <Contents>oraJDBC</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="user">
    <Contents>sni_guest</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="port">
    <Contents>3720</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="hostname">
    <Contents>uxsys186v</Contents>
    </StringRefAddr>
    <SecureRefAddr addrType="password"/>
    <StringRefAddr addrType="serviceName">
    <Contents>snit0.world</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="DeployPassword">
    <Contents>true</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="oraDriverType">
    <Contents>thin</Contents>
    </StringRefAddr>
    </RefAddresses>
    </Reference>
    </References>
    All the taskflows avaialble in my jar using the URL connection which mentioned above. But the adflibray jar got created with a file named 'jar-connection.xml', where i can see <Reference/> as an empty Tag. Because i have selected connections name only as an option when creating the adflibrary for my UI.
    Hence it is appearing so ... But when i added this jar to the other application, i have dragged & dropped the taskflows as a region on to the JSPX page. And i started running the page. On the page .... i can see only the data which is not making use of MapServer connection defiition. Along with that, some maps needs to rendered .. but that is not happening. Rest of the page with the filter critieria is being displayed properly.
    Now i have selected Include Connection Details as an option, by editing the adfLibrary Deployment profile of the UI & redeployed & found the same thing. Like, though i specify the Include Connection Details as an option ... i did not see those URL connection details in my jar-connection.xml file.Still it is not working.
    All the taskflows inside the jar are trying to use this URL connection from jar-connection.xml, which is avaiable inside the adfLibUI.jar.
    I tried with a scenorio some thing like ... For the application to which i have added this adfUILibrary, there itself i created a URLConnection ... but it did not worked as well.
    Requesting you to let me know how can i get avail of my URL connection in to my jar ...
    Thanks & Regards,
    Kiran Konjeti

    This is purely ssl issue. You can try adding the below logic first.. This code basically sets ssl properties for us.
    import java.security.Security;
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    Properties properties = System.getProperties();
    String handlers = System.getProperty("java.protocol.handler.pkgs");
    if (handlers == null) {
        // nothing specified yet (expected case)
        properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
    else {
        // something already there, put ourselves out front
        properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol|".concat(handlers));     
    System.setProperties(properties);
    Below you start your code....

  • How to make pool of  url connections in wls?

    Hi, i have a project in which i have to make a http post to multiple web
              servers to retrieve
              XML files in response to user requests. Right now i just open the
              url for each request.
              Is there any way to pool URL connections in weblogic
              thanks
              wasiq
              

    Are u using Custom Connection Pool or some App Servers Conn Pool for LDAP Connection?
    If you are opening LDAP Connection in your program code and wondering how to monitor, then it needs to be done on the LDAP Server side. Not from the application.

  • Regarding URL Connection Creation.

    Hi,
    I am trying to create a URL Connection in JDev 11.1.2, and using the following JDev RSS URL:
    http://www.oracle.com/ocom/groups/public/@otn/documents/webcontent/132361.xml
    However, when I am testing the connection, its saying "Specified URL Connection is not accessible.".
    However, the same link when I access from the browser, its accessible.
    I have tried setting the proxy as well but same result.
    Is this a known issue or am I missing something?
    Thanks,
    Lalit.

    Lalit,
    It is almost certainly a problem with your proxy configuration, as it works fine for me (with no proxy in between).
    John

  • Set timeout for URL connection in java1.4

    hi
    I want to set timeout for URL connection in java 1.4..
    java 5.0 provides with a setTimeout(int ) method but how should it be done in 1.4 environment
    Thanks in advance
    sneha

    sun.net.client.defaultConnectTimeout (default: -1)
    sun.net.client.defaultReadTimeout (default: -1)
    See the [Networking Properties|http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html].

  • Encrypting authentication details - HTTP URL Connection

    Hi,
    We have a Java application which retreives HTML content from intranet page using HTTPURLConnection, displays the portion of the content. The site to which we are connecting using HTTPURLConnection requires baisc user authentication and we are passing the user name and passowrd using BASE 64 encoding in the request header. Now this intranet site is going to be hosted externally. Just wanted to know the different options on how to send the user name and password in ecnrypted format.Is the recommendation is just to enable HTTPS for that site and pass user name and password using HTTP URL Connection API? Or are there any other options? Appreciate any inputs.
    Thanks.

    http://java.sun.com/javase/6/docs/technotes/guides/net/http-auth.html

  • HttpsURLConnection URL connection issue

    Hi All,
    I need to create URL connection with HTTPS URL. I can run Main java class successfully in machine which hosted in SAP Java server, but fail to run integrate it with e-commence application. When depployed in to SAP Java server cannot open HttpsURLConnection and always return CalssCastexception. However same code run as Java Main class
    Is this can be a (SSL) Handshake? or is this SSL issue?
    MyCode:
    String httpsURL = "https://encrypted.google.com/";
        URL myurl = new URL(httpsURL);
        HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
        InputStream ins = con.getInputStream();
        InputStreamReader isr = new InputStreamReader(ins);
        BufferedReader in = new BufferedReader(isr);
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
          System.out.println(inputLine);
        in.close();
    Thank You

    This is purely ssl issue. You can try adding the below logic first.. This code basically sets ssl properties for us.
    import java.security.Security;
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    Properties properties = System.getProperties();
    String handlers = System.getProperty("java.protocol.handler.pkgs");
    if (handlers == null) {
        // nothing specified yet (expected case)
        properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
    else {
        // something already there, put ourselves out front
        properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol|".concat(handlers));     
    System.setProperties(properties);
    Below you start your code....

  • Http Request through URL Connection?

    Hi ,
    Iam using an Applet (under JRE 1.3.0). Iam trying to send a Http Request using URL Connection. It is working fine . However, if the response time of the server is more than 3 minutes , the Response is not coming back to the server and the Applet is in a loop trying to read from the Server. I have observed that the request is sent to the server and it is processed successfully.
    When I test it in my local devp. machine it is working fine till 15 minutes which is my requirement.
    Can anybody suggest what should be the possible reasons and any workaround for it?
    Regards,
    TejoKiran.Y

    Iam copying the code fragments for the Applet Iam using . Is it a problem with the code? I heard that the URLConnection never times out . How is that it is not able to read the Response?
    <CODE >
    <HttpMessage>
    public class HttpMessage {
    URL servlet = null;
    Hashtable headers = null;
    public HttpMessage(URL servlet) {
    this.servlet = servlet;
    public InputStream sendGetMessage(Properties args) throws IOException {
    String argString = ""; // default
    if (args != null) {
    argString = "?" + toEncodedString(args);
    URL url = new URL(servlet.toExternalForm() + argString);
    // Turn off caching
    URLConnection con = url.openConnection();
    con.setUseCaches(false);
    // Send headers
    sendHeaders(con);
    return con.getInputStream();
    private void sendHeaders(URLConnection con) {
    if (headers != null) {
    Enumeration enum = headers.keys();
    while (enum.hasMoreElements()) {
    String name = (String) enum.nextElement();
    String value = (String) headers.get(name);
    con.setRequestProperty(name, value);
    </HttpMssage>
    <Code used to Read the Response.>
                        URL url = new URL(getDocumentBase(),"/ccls/test/delay.jsp");
                        HttpMessage msg = new HttpMessage(url);
                        InputStream in = msg.sendGetMessage(null);
                             char[] buff = new char[2048];
                             int bytesRead;
                             int ch;
                             StringBuffer sbtextbox = new StringBuffer("");
                             DataInputStream data = new DataInputStream(
                                                           new BufferedInputStream(in));
                             String line;
                        while ((line = data.readLine()) != null) {
                                  sbtextbox.append(line+"\r\n");
    </Code used to Read the Response.>
    </CODE>

  • Ssl URL connection

    Does anybody know if a way in jdk 1.3 to open a URL connection using SSL. I know of the javax.net.ssl.HttpsURLConnection class in 1.4 but it wasn't in the JSSE jar files I downloaded? Has anyone any ideas?

    It is definetely in there! But you will need to register the url factory to be able to use https. Take a look on the read me for JSSE install.

  • How set up URL Connection Factory/Resource?

    Hi,
    How to set up URL connection Factory, Exactly like JDBC connection Pool i.e. specifying
    Max. No. of Connection, Intial capacity etc.
    I'm able to find this much only.
    <WebServer URLResource="weblogic.httpd.url.myURL=http://localhost:7701/blah"
    />
    But If i want to set Max. Capacity/ Intial capacity for URL Connection Factory,
    Where to specify it?
    Will you please help me?
    Regards,
    Devendra

    Hi,
    The Simplest Way to Load a Property file (Which is outside of your Application) ..is.
    Just Place the Property file in the Server Classpath...or in the "C:\bea103\user_projects\domains\7001_Domain\lib" folder of your Domain. It means somehow the Property file should be available in the Server Classpath...
    Now Please write the following code in your Application to read the Property file:
    java.util.Properties prop = new java.util.Properties();
    java.io.InputStream stream=this.getClass().getClassLoader().getResourceAsStream(“my.properties”);
    prop.load(stream);
    String hostProperty = p.getProperty(“host.name”);
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com/generalweblogic/   (WebLogic Wonders Are Here)

  • Could not contact the agent. check wheather the url connected to the agent.

    i am having the problem with the error message " could not contact the agent. check wheather the url connected to the agent is null". This error occurs while login with credentials, and because of this i cant open the em page, please help me to solve this problem

    Hi,
    Can you please confirm the following:
    1. Are you trying to login to Grid Control, when you are getting this error?
    2. If yes, what was the version of Grid Control?
    3. Provide the output of commands:
    ./emctl status oms -details
    ./emctl status agent
    Best Regards,
    Venkat

  • Junit : how to create JDBC URL connection

    hi folks,
    I am implementing JUnit in my application , for that I have seen srdemo application every thing is fine but i havent get how to configure JDBC URL connection 'SRServiceLocalTesting' ? can any body tell me how to do it.
    Thanks in advance
    Regards
    Pravin

    Hi,
    Have a look,
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/odi/odi_11g/odi_project_xml-to-table/odi_project_xml-to-table.htm
    Thanks,
    Guru

  • Opening URL Connection

    Hi all,
    I'm having a problem when connecting to a URL that is non-esisting using a while loop to catch the exception but no exception is being thrown.
    while(myConn == null || !found)
    try
    myConn = url.openConnection();
    } //IOException
    catch (Exception Expt)
    System.out.println("Cannot open URL connection");
    java.lang.Thread.sleep(3000);
    myConn = null;
    continue;
    Cheers
    JavaJimmyD

        BufferedReader inp = null;
        try {
          URL url = new URL(urlString);
          URLConnection conn = url.openConnection();
          conn.setDoInput(true); // or setDoOutput(true)
          /* really open connection */
          conn.connect(); // establish connection
          inp = new BufferedReader(
                  new InputStreamReader(conn.getInputStream()));
          String result = inp.readLine(); // or your stuff
          inp.close();  // close connection
          inp = null;
        catch (MalformedURLException ue) {}
        catch (Exception e) {}
        finally {
          try { if (inp != null) inp.close(); } catch(IOException e) {}
        }

  • ADF mobile url Connection

    Not able to make connection for the rest urls of the webcenter spaces(like rest urls to fetch activities list , discussion)
    Ex: Tried Connecting the url :http://localhost:8888/rest/api/resourceIndex with the basic authentication ,but got an exception message as:"Specified url is not accessible"
    Edited by: user12780347 on Nov 14, 2012 8:43 PM

    Hi, ADF Mobile uses the same URL Connection creation wizard as any other ADF application, so its behavior is not mobile specific. That said, you may want to try the following:
    - append "/" to the end and see if that helps
    - If using WLS security with basic HTTP Authentication, ensure the "Realm" field is populated correctly based on your WLS setup.
    The error message indicates that it's able to resolve "localhost" but just can't connect to this REST service. If you are getting proxy server issue, then you will probably get "host not reacheable" error.
    One thing to double check is whether you get the basic HTTP auth challenge when you use a browser to hit this link.
    Lastly, you probably don't want to use localhost in the URL data control. Only iOS simulators can resolve "localhost" when the iOS simulator and the WLS server are running in the same machine. Android can't. Recommendation is to set up your WLS so it can be accessed with the machine's actual IP address, and you would create your URL data control to against that real IP. This would ensure both emulators and devices can hit the JSON service.
    Thanks,
    Joe Huang

  • Big headache with URL connection

    Hi, guys.
    i wrote an applet that measures response time of some html components, like gifs! The applet should return this wasted time by the actionperform method be executed, since this method opens a url connection with a html component. So it might return the final response time, but the result is always 0 !!! Please, could anybody help me?
    Regards Euclides.
    public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
    long valor;
    Integer valornovo;
    String valor1,tam1,tarefa1;
    JTextField aux;
    tam1 = (String)ivjJComboBox1.getSelectedItem();
    tarefa1 = (String)ivjJComboBox2.getSelectedItem();
    valor = mandabala(tam1,tarefa1);
    valor1 = Long.toString(valor);
    //delayField = new JTextField(Long.toString(delay), 6);
    //valor1 = Long.toString(valor);
    ivjJTextField1.setEnabled( true );
    ivjJTextField1.setText(valor1);
    validate();
    public long mandabala(String param, String param1) {
    long time;
    long time1;
    BufferedInputStream in;
    java.net.HttpURLConnection conn;
    java.net.URL url;
    url = null;
    if (param == "100")
    byte[] buffer = new byte[99990000];
    try {
    url = new java.net.URL("http://10.0.135.15/teste.gif");
    // url = constructURL("http://10.0.135.15/performance/teste.gif");
    conn = (HttpURLConnection)url.openConnection();
    time = System.currentTimeMillis();
    //conn("http://www.dataprev.gov.br/performance/teste.gif");
    //conn("http://10.0.135.15/performance/teste.gif");
    conn.connect();
    time1 = System.currentTimeMillis();
    in = new BufferedInputStream(conn.getInputStream());
    int x = 0;
    while((x = in.read(buffer))!=-1)
    timedif = System.currentTimeMillis() - time;
    in.close();
    catch(Exception e) {
    System.out.println("Erro de conexao");

    I read it really quickly, so I apologize if you've checked this already...
    Your while loop is not executing the statement you are using to compute the timediff variable. The while loop in.read() method returns with a value of say '63000' when the .gif file is read. Since 63000!=-1 the loop exits immediately without executing the statement (System.currentTime()) in the middle.
    To correct this, you should do the following.
    long timediff=0;
    long starttime=System.currentTimeInMillis();
    int character=0;
    while( (character=in.read()) != -1 );
    timediff = System.currentTimeINMillis() - starttime;
    //return timediff;

Maybe you are looking for

  • Lightbox images not showing when uploaded to my website

    Hello I'm creating a new website for my photography business, and have created three 'gallery' pages which are basically just a lightbox gallery on each page with 20 images in. I uploaded my first page, gallery1, and the associated images and went to

  • InDesign all versions: is there a rectangle widget...

    I need to draw a rectangle on a dialog, fill it with white background and then place a text box and another custom widget on top of it.  Is therea already a widget that will provide me with this functionality, or do I need to write my own custom widg

  • My wish list on iTunes missing

    my wishlist on ITunes missing??? why?

  • IPhoto 9.6.1 can't compare photos?!?!

    Okay, so all of Apple's support documents say if you have two images highlighted in an album you can click the 'Edit' button & they will display side-by-side so you can compare and/or edit them. A more complex process than on previous iPhoto version

  • Capturing LOV Return Item in a field of JSP Page

    Dear Members,4 I am using JDev 10g (10.1.3.5.0) Requirement: I want to display a LOV for a field which is not bound to data model. To achieve this requirement I have follwed the below steps. Steps:- I have a simple JSP page in which there is a select