Ticket Change Details
Overview

Artifact ID: 735b6ddee6a400bd89f26c511f2c8ab25f8647b57dcb659458fcc9761a1ee687
Ticket: 48eddca89ea79b5cb6477d5f9f46cc890873cf92
http:geturl https://localhost:8143/info hangs when server not running
User & Date: bohagan on 2026-02-06 03:21:45
Changes

  1. icomment:
    The issue was fixed as noted in the commits listed previously, just not exactly as you suggested. See lines 230-253 in tlsIO.c:
    
    	if (ret <= 0) {
    	    if (rc == SSL_ERROR_WANT_CONNECT || rc == SSL_ERROR_WANT_ACCEPT) {
    		bioShouldRetry = 1;
    	    } else if (rc == SSL_ERROR_WANT_READ) {
    		bioShouldRetry = 1;
    		statePtr->want |= TCL_READABLE;
    	    } else if (rc == SSL_ERROR_WANT_WRITE) {
    		bioShouldRetry = 1;
    		statePtr->want |= TCL_WRITABLE;
    	    }
    	}
    
    	if (bioShouldRetry) {
    	    dprintf("The I/O did not complete -- but we should try it again");
    
    	    if (statePtr->flags & TLS_TCL_ASYNC) {
    		dprintf("Returning EAGAIN so that it can be retried later");
    		*errorCodePtr = EAGAIN;
    		return 0;
    	    } else {
    		dprintf("Doing so now");
    		continue;
    	    }
    	}
    
    -------------------
    
    I just tested it with the below script on both Windows and Linux and it worked on both. See below:
    
    -------------------
    
    Script
    
    package require Tcl
    package require http
    package require tls
    ::http::register https 443 ::tls::socket
    
    set token [::http::geturl https://localhost:8143/info -timeout 3000]; # use port with no service listening here!
    http::status $token
    
    
    -------------------
    
    OpenSUSE 16.0
    
    Brian@Blizzard:~> /usr/bin/tclsh
    % package require Tcl
    8.6.17
    % package require http
    2.9.8
    % package require tls
    2.0
    % ::http::register https 443 ::tls::socket
    443 ::tls::socket
    % set token [::http::geturl https://localhost:8143/info -timeout 3000]; # use port with no service listening here!
    connect failed connection refused
    % http::status $token
    can't read "token": no such variable
    % exit
    
    Brian@Blizzard:~> /opt/tcl9/bin/tclsh9.0
    % package require Tcl
    9.0.3
    % package require http
    2.10.1
    % package require tls
    2.0
    % ::http::register https 443 ::tls::socket
    443 ::tls::socket {} 0 0
    % set token [::http::geturl https://localhost:8143/info -timeout 3000]; # use port with no service listening here!
    connect failed: connection refused
    % http::status $token
    can't read "token": no such variable
    %
    
    -------------------
    
    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    
    C:\Users\Brian>c:\TCL\bin\tclsh
    % package require Tcl
    8.6.14
    % package require http
    2.9.8
    % package require tls
    2.0
    % ::http::register https 443 ::tls::socket
    443 ::tls::socket
    % set token [::http::geturl https://localhost:8143/info -timeout 3000]; # use port with no service listening here!
    connect failed connection refused
    % http::status $token
    can't read "token": no such variable
    % exit
    
    C:\Users\Brian>c:\TCL9\bin\tclsh
    % package require Tcl
    9.0.3
    % package require http
    2.10.1
    % package require tls
    2.0
    % ::http::register https 443 ::tls::socket
    443 ::tls::socket {} 0 0
    % set token [::http::geturl https://localhost:8143/info -timeout 3000]; # use port with no service listening here!
    connect failed: connection refused
    % http::status $token
    can't read "token": no such variable
    %
    
  2. login: "bohagan"
  3. mimetype: "text/plain"