Arc Forumnew | comments | leaders | submitlogin
Srv thread took too long for xx.yy.zz.ww in Anarki
1 point by lark 4646 days ago | 8 comments
When uploading an 85929 byte file in Anarki, the following error shows up:

  srv thread took too long for xx.yy.zz.ww


2 points by rocketnia 4646 days ago | link

That didn't show up until 30 seconds had passed, right?

It's easy to find the code where this takes place:

  $ grep "took too long" . -r
  ./lib/srv.arc:                 (prn "srv thread took too long for " ip))
It's an intentional feature of 'handle-request. It waits for 'threadlife* seconds (30) and then gives up. Maybe you need to set 'threadlife* to a larger value for your application... but since 30s for an 86KB upload is pretty ridiculous, maybe there's another issue.

-----

1 point by lark 4646 days ago | link

Makes sense. Here's the issue: how do I save the multipart data of an file upload to a file quickly? Is there something more efficient than this:

  (w/outfile o f
    (whilet c (and (> n 0) (readc req!in))
              (-- n)
              (disp c o)))
This is derived from: http://github.com/nex3/arc/blob/master/lib/webupload.arc

Using a:

              (writec c o)))
produces the same effect.

-----

2 points by rocketnia 4646 days ago | link

I found some cool stuff at (http://docs.racket-lang.org/reference/port-lib.html#(def._((...).

This might work:

  (w/outfile o f
    (let i ($.make-limited-input-port req!in n)
      (after ($.copy-port i o)
        close.i)))
For all I know, closing i may not be necessary:

  (w/outfile o f
    ($.copy-port ($.make-limited-input-port req!in n) o))
Note that this copies n bytes. The code you posted deals with n characters for some reason, even though Arc provides 'readb and 'writeb for dealing with bytes.

-----

1 point by lark 4645 days ago | link

Thanks for the help. I tried with readb instead of readc and received a browser error with the 874996-byte file.

-----

1 point by lark 4646 days ago | link

It seems saving w/outfile saves the file correctly as sent. It's just that Anarki does not return after that.

Also, uploading a 874996-byte file results into only 183045 of those bytes being available in the multipart data that end up being saved, and the browser reports an error:

  The webpage at http://lovelywebsite.com/x?fnid=6bl1DEG5yq
  might be temporarily down or it may have moved permanently
  to a new web address.
Also, when this error uploading a 874996-byte file occurs, the 'srv thread took too long' error message is not displayed at all: the browser error occurs within 1-2 secs.

-----

2 points by rocketnia 4646 days ago | link

That sounds almost like you're coming across a request size limit somewhere in your server (maybe in news.arc or app.arc or srv.arc, maybe in Apache or nginx or whatever)... but probably not since the upload is less than 4MB. All I know is PHP tends to limit uploads to 4MB unless you reconfigure it. :-p

Maybe you're coming across an issue with the fact that bytes are being treated as characters? Do you have another file you could test? (Maybe one you could share with us?)

-----

1 point by lark 4645 days ago | link

I thought there might be a request size limit, since there's an nginx in front of Anarki. But then I tried connecting directly to the Anarki web port and got the same result.

Here's a 822K file which I just confirmed fails to be uploaded:

http://tyche.pu-toyama.ac.jp/~a-urasim/lsvl/data/bzip2_1.0.5...

Can anyone get this to upload with webupload.arc successfully?

-----

1 point by rocketnia 4641 days ago | link

Sorry for leaving you hanging here.... I'm not really in the practice of running news.arc, and when I asked for a file to use for testing it's because I thought maybe someone else would pick up my slack. XD

-----