Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Timeout during connect

Open874321ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 4 years ago
Descriptionplain2004-01-10 07:58:31
If http::geturl used with -timeout > 0 it may timeout in the 
middle of the transaction since there is no after cancel 
except in http::Finish which is too late.

Fix:
Add this to http::Connect

if {[info exists state(after)]} {
    after cancel $state(after)
    unset state(after)
}
dkf Ticket [874321ffff]: 2 changes [History diff]2004-01-12 19:58:25
dgpplain2004-01-13 14:27:26
Logged In: YES 
user_id=80530

Is this really a bug?

You asked the connection to timeout
after some period, and it did.  The docs
don't say anything about canceling the
timeout just because activity starts
on the connection.
matbenplain2004-01-13 15:54:00
Logged In: YES 
user_id=108900

timeout is timeout only for the socket to connect. It is not 
a timeout for the file transport since this can take hours 
for large files.
dkfplain2004-01-13 16:19:22
Logged In: YES 
user_id=79902

Hmm.  Is it possible to update/cancel the timeout on an HTTP
connection?  If not and we added it, I think it would allow
the sort of sophisticated behaviour that Mat's after.
matbenplain2004-01-13 18:52:40
Logged In: YES 
user_id=108900

This is not a sophisticated behaviour. It is standard that 
any timeout is only applicable to the socket connecting. If 
you want to cancel an existing http query just use 
http::reset (I think).
nobodyplain2004-05-07 08:59:42
Logged In: NO 

I think that both arguments are valid. I would use the
current timeout to cancel a http remote procedure call, but
I would also like to have a -connectTimeout option to abort
the process if a connection can not be made. By default, the
TCP/IP timeout of 2 minutes is in effect, but that is too
long for most situations. I proposed this some years back
and was dismissed. Since TCL 8.0 I have been tweaking every
release of http to add a -connectTimeout option to the
http::get method.
hobbsplain2004-05-26 05:11:13
Logged In: YES 
user_id=72656

This is the documented behavior.  You don't want the timeout
reset once the socket just becomes writable, the timeout is
for the entire transaction.  If you have a long-running
transaction, you want it to timeout at any phase of geturl.
dkf Open ticket [874321ffff]. [History diff]2004-05-26 15:18:17
dkf Ticket [874321ffff]: 1 change [History diff]2004-05-26 15:18:52
dkfplain2006-06-30 15:20:44
Logged In: YES 
user_id=79902

What's really missing is the ability to do the DNS lookup
asynchronously when doing a [socket -async]. But that's very
tricky (and I think is a different FRQ).

Aside from that, adding the ability to set different
timeouts for different stages of the [geturl] processing
would be a nice extension. Assigning to area maintainer so
this doesn't get lost.
patthoytsplain2006-12-09 03:10:41
Logged In: YES 
user_id=202636
Originator: NO

I agree that there are two different timeouts being covered here. The current -timeout option is documented as a global timeout that covers not just the connection phase but the whole transaction. What is being requested is a separate connection-only timeout that should be cancelled once we have a tcp connection to the server. I suspect that on most occasions that there is a problem in this phase it is actually a DNS lookup issue and in this case we are blocked in the C runtime and cannot actually do anything about it.
kjnashplain2022-09-09 16:50:33
For the DNS lookup issue, see also bug [824251] "async client sockets block for DNS" in Sec. 27 "Channel Types".  http::geturl now has an optional workaround that allows the script to wait in the event loop while the connection is made.

Another possible interpretation of "timeout" is that it applies after a period of inactivity - not only when creating the socket, but at any time in the transaction.  This would not be difficult to implement - the timeout event would be cancelled and re-started whenever an event handler is called.

However, we do not need two timeout flags.  The documented -timeout remains.
Log in (anonymous is fine) to add a comment.