<i>Problem with ::http::OpenSocket in HTTP module (library/http/http.tcl) since Tcl 9.0.x</i>.
by
.
D 2026-10-01T12:02:40.466
J assignee nobody
J closer nobody
J cmimetype text/plain
J comment Hello,\severybody\r\n\r\nWe\sare\scurrently\sin\sthe\sprocess\sof\sporting\sour\sapplication\sfrom\sTcl/Tk\s8.6\sto\s9.0.\sIn\sthe\sprocess,\swe\shave\sencountered\sa\sproblem\swith\szooming\sin\sand\sout\swithin\sour\sWMS\s(Web\sMap\sService)\smodule.\r\n\r\nThe\serror\soccurs\sunder\sLinux\s(openSUSE\sLeap\s16.0\sand\sDebian\s13)\swith\sTcl\s9.0.3\s(and\smost\slikely\swith\s9.0.4\sas\swell),\sbut\snot\swith\sTcl\s8.6.16.\r\n\r\nThe\ssource\scode\sfor\sTcl\s9.0.3\scontains\sthe\sfile\s`library/http/http.tcl`,\sand\sline\s1727\sreads\sas\sfollows:\r\n\s\s\s\sset\ssock\s[namespace\seval\s::\s$state(openCmd)]\r\nHere,\sthe\scommand\spreviously\sregistered\svia\s`http::register`\sis\sexecuted.\sIf\sthis\scommand,\sfor\sexample,\sexecutes\sa\s`vwait`\s(as\soccurs,\sfor\sinstance,\sin\sthe\s`autoproxy`\spackage\s[autoproxy::tls_socket]),\sthen\sevents\sare\sprocessed\sin\sthe\smeantime\sand\stheir\shandlers\sare\sexecuted.\sThese\shandlers\scan,\sin\sturn,\scall\s`http::reset`\sand\s`http::cleanup`,\sso\sthat\sthe\stoken\s(the\svariable\s`state`\sin\s::http::OpenSocket)\sno\slonger\sexists\safter\sreturning\sfrom\sline\s1727.\r\n\r\nThe\sHTTP\smodule\sthen\sterminates,\sfor\sexample,\swith\sthe\sfollowing\serror\smessage,\swhich\sis\sdifficult\sto\scatch/handle:\r\n\s\s\s\scan't\sread\s"state(-keepalive)":\sno\ssuch\selement\sin\sarray\r\n\r\nI\shave\sattached\sa\ssmall\sscript\sthat\scan\sbe\sused\sto\sreproduce\sthe\serror,\sand\salso\sa\squick-and-dirty\spatch\s(see\sbelow).\r\n\r\nKind\sregards,\r\n\r\nRobert\r\n\r\n#!/usr/bin/env\swish\r\npackage\srequire\shttp\r\npackage\srequire\stls\r\n\r\nwm\stitle\s.\s"Logo"\r\nwm\sminsize\s.\s300\s300\r\n\r\nset\swaitForMe\s0\r\n\r\nproc\slameTlsSocket\s{args}\s{\r\n\s\s\s#\sLet's\swait\sa\slittle\sbit\r\n\s\s\svwait\s::waitForMe\r\n\s\s\sreturn\s[tls::socket\s{*}$args]\r\n}\r\nhttp::register\shttps\s443\slameTlsSocket\r\n\r\nlabel\s.label\s-text\s"Use\sthe\skeyboard\sor\smouse\sto\sgenerate\sa\sseries\sof\sevents"\s-wraplength\s300\r\npack\s.label\s-expand\s1\r\n\r\nproc\sgetLogo\s{args}\s{\r\n\s\s\s.label\sconfigure\s-image\s""\r\n\r\n\s\s\sif\s{[info\sexists\s::currentRequest]}\s{\r\n\s\s\s\s\s\s#\sStop\scurrent\srequest\r\n\s\s\s\s\s\sputs\s"Stop\scurrent\srequest\s$::currentRequest"\r\n\s\s\s\s\s\shttp::reset\s$::currentRequest\r\n\s\s\s}\r\n\r\n\s\s\s#\sStart\snew\srequest\r\n\s\s\sset\s::currentRequest\s[http::geturl\s"https://thumb.wikimedia.org/wikipedia/commons/thumb/4/41/Tcl.svg/120px-Tcl.svg.png"\s-command\sdisplayLogo]\r\n\s\s\sputs\s"New\srequest\s$::currentRequest"\r\n}\r\nbind\s.\s<MouseWheel>\sgetLogo\r\nbind\s.\s<Button>\sgetLogo\r\nbind\s.\s<Key>\sgetLogo\r\n\r\nproc\sdisplayLogo\s{token}\s{\r\n\s\s\sif\s{[http::status\s$token]\seq\s"ok"}\s{\r\n\s\s\s\s\s\sset\sdata\s[http::data\s$token]\r\n\s\s\s\s\s\stry\s{\r\n\s\s\s\s\s\s\s\s\simage\screate\sphoto\slogo\s-format\spng\s-data\s$data\r\n\s\s\s\s\s\s\s\s\s.label\sconfigure\s-image\slogo\r\n\s\s\s\s\s\s}\son\serror\s{err}\s{\r\n\s\s\s\s\s\s\s\s\sputs\s$err\r\n\s\s\s\s\s\s}\r\n\s\s\s}\r\n\r\n\s\s\sputs\s"Cleanup\s$token"\r\n\s\s\shttp::cleanup\s$token\r\n\r\n\s\s\sif\s{$token\seq\s$::currentRequest}\s{\r\n\s\s\s\s\s\sunset\s::currentRequest\r\n\s\s\s}\r\n}\r\n\r\nproc\sgoOn\s{}\s{\r\n\s\s\sincr\s::waitForMe\r\n\s\s\safter\s1000\sgoOn\r\n}\r\ngoOn\r\n###\sEND\sOF\sSCRIPT\r\n\r\n---\slibrary/http/http.tcl\r\n+++\slibrary/http/http.tcl\r\n@@\s-1754,7\s+1754,7\s@@\r\n\s\s\s\s\sdict\sunset\ssocketCoEvent($state(socketinfo))\s$token\r\n\s\s\s\s\sunset\s-nocomplain\sstate(socketcoro)\r\n\r\n-\s\s\s\sif\s{[catch\s{\r\n+\s\s\s\stry\s{\r\n\s\s\s\s\s\s\s\sif\s{$state(reusing)}\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\s#\sIf\s($state(reusing))\sis\strue,\sthen\swe\sdo\snot\sneed\sto\screate\sa\snew\r\n\s\s\s\s\s\s\s\s\s\s\s\s#\ssocket,\seven\sif\s$sockOld\sis\sonly\sa\splaceholder\sfor\sa\ssocket.\r\n@@\s-1765,6\s+1765,10\s@@\r\n\s\s\s\s\s\s\s\s\s\s\s\s##Log\spre\ssocket\sopened,\s-\stoken\s$token\r\n\s\s\s\s\s\s\s\s\s\s\s\s##Log\s$state(openCmd)\s-\stoken\s$token\r\n\s\s\s\s\s\s\s\s\s\s\s\sset\ssock\s[namespace\seval\s::\s$state(openCmd)]\r\n+\s\s\s\s\s\s\sif\s{![info\sexists\sstate]}\s{\r\n+\s\s\s\s\s\s\s\s\s\scatch\s{close\s$sock}\r\n+\s\s\s\s\s\s\s\s\s\sreturn\r\n+\s\s\s\s\s\s\s}\r\n\s\s\s\s\s\s\s\s\s\s\s\sset\sstate(sock)\s$sock\r\n\s\s\s\s\s\s\s\s\s\s\s\s#\sNormal\sreturn\sfrom\s$state(openCmd)\salways\sreturns\sa\svalid\ssocket.\r\n\s\s\s\s\s\s\s\s\s\s\s\s#\sA\sTLS\sproxy\sconnection\swith\s407\sor\sother\sfailure\sfrom\sthe\r\n@@\s-1791,7\s+1795,7\s@@\r\n\s\s\s\s\s\s\s\s#\sCode\sabove\shas\sset\sstate(sock)\s$sock\r\n\s\s\s\s\s\s\s\sConfigureNewSocket\s$token\s$sockOld\s$DoLater\r\n\s\s\s\s\s\s\s\s##Log\sOpenSocket\ssuccess\s$sock\s-\stoken\s$token\r\n-\s\s\s\s}\sresult\serrdict]}\s{\r\n+\s\s\s\s}\son\serror\s{result\serrdict}\s{\r\n\s\s\s\s\s\s\s\s##Log\sOpenSocket\sfailed\s$result\s-\stoken\s$token\r\n\s\s\s\s\s\s\s\s#\sThere\smay\sbe\sother\srequests\sin\sthe\ssocketPhQueue.\r\n\s\s\s\s\s\s\s\s#\sPrepare\ssocketPlayCmd\sso\sthat\sFinish\swill\sreplay\sthem.
J foundin 9.0.3
J is_private 0
J login robgcs
J priority 5\sMedium
J private_contact 46a2e3583f4f71c2c357a51bf39365bc9937aa6f
J resolution None
J severity Critical
J status Open
J submitter robgcs
J subsystem 29.\shttp\sPackage
J title Problem\swith\s::http::OpenSocket\sin\sHTTP\smodule\s(library/http/http.tcl)\ssince\sTcl\s9.0.x
J type Bug
K 0c1e91d072c70f305933d98bc2b24e1c5bf8e48a
U robgcs
Z 0072f2d897cb2d4dff1806c51ef75161