You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Pa...@ubs.com on 2007/12/10 13:29:13 UTC

isOpen returns true even when network interface disabled

Hi All,

Im having difficulty finding a good way to determine whether or not my
connections are actually open before I send my message to the server.
Im using the MTHCM, I have one thread responsible for sending messages
and another thread responsible for checking the connection.  To check
the connection i use the getConnection method from MTHCM, then call
isOpen().  This method returns true even when Ive disabled my network
interface.  I have setStaleCheckingEnabled = true.

Is there an easy way to check if my sockets are still open?  I assume
that Im using the library incorrectly but I can not find any other
reference to a similar issue.

Any help would be much appreciated.

Regards,

Paolo Mentonelli

Re: isOpen returns true even when network interface disabled

Posted by Roland Weber <os...@dubioso.net>.
Hello Paolo,

HttpConnection.isOpen just checks the boolean flag in the
connection object, it doesn't perform any calls to the
underlying socket. Try calling conn.closeIfStale() before
checking if the connection is open:
http://jakarta.apache.org/httpcomponents/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpConnection.html#closeIfStale()

I can't tell whether that is reliable, though.

hope that helps,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: isOpen returns true even when network interface disabled

Posted by Raymond Kroeker <ra...@raykroeker.com>.
Hi Paolo,

  Something to remember is that tcp/ip is stateless.  Therefore any higher
level protocol is susceptible to this nature.  Http does not provide
provision for state; therefore http-client can do nothing other than check
flags for previously known states in order to determine whether or not a
connection is open.

  This means that at any given point in time; isOpen could be inconsistent
with the network connection's actual state.  If you check the socket
implementation from the JDK you'll see too that its isConnected api simply
returns internal state as well which could be inconsistent with the actual
state.

Raymond


On Dec 10, 2007 4:29 AM, <Pa...@ubs.com> wrote:

>  Hi All,
>
> Im having difficulty finding a good way to determine whether or not my
> connections are actually open before I send my message to the server.  Im
> using the MTHCM, I have one thread responsible for sending messages and
> another thread responsible for checking the connection.  To check the
> connection i use the getConnection method from MTHCM, then call isOpen().
> This method returns true even when Ive disabled my network interface.  I
> have setStaleCheckingEnabled = true.
>
> Is there an easy way to check if my sockets are still open?  I assume that
> Im using the library incorrectly but I can not find any other reference to a
> similar issue.
>
> Any help would be much appreciated.
>
> Regards,
>
> Paolo Mentonelli
>
> Based on the present E-Mail exchange, and/or on the agreement reached
> with you, respectively, UBS is entitled to contact you via insecure
> E-Mail:
> (a) E-Mails contain substantial risks such as lack of confidentiality,
> manipulation of content and sender, misdirection, viruses etc. UBS
> does not accept any liability for damages arising from use of
> E-mail. Accordingly, UBS recommends to abstain from sending any
> sensitive information via E-Mail, from forwarding the text received
> when submitting reply E-Mails and recommends to manually capture the
> E-Mail address in every instance. If you should wish to verify the
> content of this message, please request a hard-copy version.
> (b) In principle, UBS does not accept any (purchase) orders,
> cancellation of orders or authorizations etc. via E-mail. If UBS
> receives such E-Mails, UBS is not obliged to expressly decline them.
> If you have received this E-Mail by mistake or do not wish to be
> contacted by E-Mail in the future, you are kindly asked to inform UBS
> accordingly. Any E-Mail received by mistake (including all its annexes)
> needs to be destroyed and the content may not be forwarded nor disclosed
> to any further persons.
> c) This message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities or
> related financial instruments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>



-- 
---------------------------------------------------------
Raymond Kroeker