[plt-scheme] Web Server Port Query (v371)

From: Eric Domeshek (domeshek at stottlerhenke.com)
Date: Tue Apr 15 12:21:57 EDT 2008

Noel Welsh wrote:
> On Tue, Apr 15, 2008 at 3:18 PM, Eric Domeshek
> <domeshek at stottlerhenke.com> wrote:
>
>   
>>  This program works on my Vista Business Lenovo tablet.  Guessing that
>> something in Vista Ultimate (or their configuration) was hogging port 80
>> already, I tried to reconfigure to run on another port.  I find I have both
>> a config.scm (in the same directory as my default-web-root), and a
>> configuration-table.scm (inside the default-web-root directory).  I suspect
>> one of them is left over from an early version of MzScheme and its web
>> server, but I'm not sure which it is.
>>     
>
> How are you running the web server?  That will tell us what files it
> is reading for its configuration.  Do those files really have
> extension .scm or is it .ss?
>   
Tracing through my way of launching the server eventually led me to the 
incantation I was using, which I see must be hard-coding the port in a 
way that overrides the config files, so that's one mystery solved.  I'm 
also guessing that of my two configuration files, the operative one must 
be the "config.scm" (rather than the deeper nested 
"configuration-table.ss"). 

It's been a while, but my memory is that this code below was something I 
cobbled together when I was migrating from v360 to v371, probably based 
on a sample someone offered me, perhaps on this list (my memory is that, 
at least at that time, the docs were not in synch with the then newish 
v371 release).  Am I correct that I don't HAVE to specify the #:port 
argument here, but could leave it to be managed by the config.scm file?

  (define *load-rel-dir* (current-load-relative-directory))
  (define *config-path*  (build-path *load-rel-dir* "collects" "its" 
"config.scm"))

  (define (s)
    #f)
 
  (define (r)
    (s)
    (let ([config (configuration-table->web-config@
                    *config-path*
                    #:port      80
                    #:listen-ip #f
                    )])
      (set! s (serve/web-config@ config))
      ))

In any case, by editing the above I've now been able to get the server 
running on another port (e.g. 8080).  Now I can at least give my user 
something else to try.

> Dunno about Vista, but none of our users have complained about anything.
>
> Also:
>
>   - You really (*really*) should consider upgrading to at least 372 if
> not the latest SVN.
>   
I moved to v371 from v360 to eliminate a bug where the server hung if 
you submitted a new request before it was finished processing a previous 
one.  In v371, the only problem I've seen (beyond growing memory 
consumption from continuation management) is that sometimes the server 
gets running in some kind of loop that pegs the processor near 100% 
utilization (but it remains responsive to further requests).  Do you 
think v372 would fix that issue?

I'm reluctant to move to a new version because (a) I've had to make a 
hack or two to other low-level libraries (e.g. in the xml libraries 
private write.ss file) that I'd need to port over, and (b) I'd need to 
run another round of testing to make sure everything else was still 
working as before.

>   - We wrote instaweb and instaservlet so we didn't have to mess
> around with this sort of stuff.  You too might find them useful.
>   
Next time I get to come up for air, I'll try to look at those packages.
> N.
>   
While I'm on the line, I might as well follow up Jay McCarthy's response 
as well.  Jay said:

> It could also have something to do with IPv6. What is the IP address
> you give in the config file?
>
> Jay
As near as I can see, there is no IP address in the config file.  I'm 
not sure what the "#:listen-ip #f" argument to 
configuration-table->web-config@ above is doing.  Here is the 
config.scm, which I now believe is the operative configuration file for 
the web server the way it's being launched.

((port 80)
 (max-waiting 40)
 (initial-connection-timeout 30)
 (default-host-table
   (host-table
     (default-indices "index.html" "index.htm")
     (log-format parenthesized-default)
     (messages
       (servlet-message "servlet-error.html")
       (authentication-message "forbidden.html")
       (servlets-refreshed "servlet-refresh.html")
       (passwords-refreshed "passwords-refresh.html")
       (file-not-found-message "not-found.html")
       (protocol-message "protocol-error.html")
       (collect-garbage "collect-garbage.html"))
     (timeouts
       (default-servlet-timeout 86400)
       (password-connection-timeout 300)
       (servlet-connection-timeout 86400)
       (file-per-byte-connection-timeout 1/20)
       (file-base-connection-timeout 30))
     (paths
      (configuration-root "conf")
      (host-root "default-web-root")
      (log-file-path "log")
      (file-root "htdocs")
      (servlet-root ".")
      (mime-types "mime.types")
      (password-authentication "passwords"))))
 (virtual-host-table))


Posted on the users mailing list.