Tclhttpd Problems with Mozilla Keep-Alive

MHo, 2007-10-23

Here are some observations I made while I restarted an old project: porting an old tclhttpd 3.4.x-site to the latest incarnations of that webserver, 3.5.1 or 3.5.2.

I use my own build of that webserver, see Tclhttpd Winservice for further information.


The problem

I noticed that if I did not specify the file extension with an URL (like .htm or .tml), sometimes excessive delays occur. The resulting page appears in the browser, if ever, only after a very long delay period. Though I discover part of the program flow and learned that such page requests are satisfied via an error which was further handled by url_rewind and so on, I couldn't find any error.

But there are two facts:

  • The behaviour is different to 3.4x-versions of the webserver.
  • The logic has been largely rewritten between 3.4x and 3.5x (the monolythic doc.tcl splits up to doc.tcl, fallback.tcl., etc.).

Today, I found out that under the absolutely same circumstances my whole tests run fine with Opera. (I also tested IE7 but it failed for other reasions, as usual....). So I inspect my SeaMonkey settings once more. Just for a last test I disabled the Keep-Alive and/or pipelining Option in the Http-Connection-Settings Page (stated as experimental), and: that did the trick!!!

yahalom the problem as far as I found is the assumption by tclhttpd that if there is no mime,connection and mime,proxy-connection in the protocol and we are working in http 1.1, then the connection should stay in keep-alive. looking at how ie 7 looks at things connection should stay alive only if the browser explicitly asked for it. if this mime does not exist then the connection should be closed. fixing the problem is done in httpd.tcl HttpdCloseP removing lines:

 } elseif {$data(version) >= 1.1} {
        Count http1.1
            set close 0

Conclusion

There must be some subtle fact that leads to odd timeout/delay problems if a page was generated through fallback/url_unwind, in conjunction with specific browser settings in some environments.

Unfortunately, my understanding of the code isn't good enough to track this problem further down. And, I fear, the whole tclhttpd isn't really maintained any more....

  • Just tested under the same conditions (ok, SeaMonkey 1.1.4 instead of 1.1.5) but on w2k (instead of xp) and without a local firewall. Everything works fine, even with pipelining turned on. The thing becomes more and more misterious...

Another one

Also, I found that some URLs where constructed like //xyz/abc within fallback.try, which leads to wrong results later:

      :
      # set url $virtual/[string trimleft $suffix /~] ; ####### old
        set url [file join $virtual [string trimleft $suffix /~]]; ###### new
        if {[info exist data(query)] && [string length $data(query)]} {
            append url ? $data(query)
        }

        Redirect_Self $url      ;# offer what we have to the client
       :

After applying that change, that error disappears.


I also reported a bug at sourceforge [L1 ], but it was a bit mazy and should be corrected and/or closed now...