<div dir="ltr">Hello, I'm not sure what is causing this error (please see the stack trace below), all I can say it's relatively big XML being sent. I must be doing something tremendously inefficient or else this error means something else, but I hope you would be able to advise:<div>
<br></div><div><div>[2011-07-06 14:20:27 [ERROR]] I/O timeout reading #<SB-SYS:FD-STREAM for "a socket" {B8E0AA1}>.</div><div>0: (SB-DEBUG::MAP-BACKTRACE #<CLOSURE (LAMBDA #) {B9034D5}>)[:EXTERNAL]</div>
<div>1: (BACKTRACE 536870911 #<SB-IMPL::STRING-OUTPUT-STREAM {B903471}>)</div><div>2: (TRIVIAL-BACKTRACE:PRINT-BACKTRACE-TO-STREAM</div><div> #<SB-IMPL::STRING-OUTPUT-STREAM {B903471}>)</div><div>3: (HUNCHENTOOT::GET-BACKTRACE)</div>
<div>4: ((FLET #:LAMBDA284) #<SB-SYS:IO-TIMEOUT {B903139}>)</div><div>5: (SIGNAL #<SB-SYS:IO-TIMEOUT {B903139}>)[:EXTERNAL]</div><div>6: (ERROR SB-SYS:IO-TIMEOUT)[:EXTERNAL]</div><div>7: (SB-IMPL::SIGNAL-TIMEOUT SB-SYS:IO-TIMEOUT)[:EXTERNAL]</div>
<div>8: (SB-IMPL::REFILL-INPUT-BUFFER #<SB-SYS:FD-STREAM for "a socket" {B8E0AA1}>)</div><div>9: (SB-IMPL::FD-STREAM-READ-N-BYTES</div><div> #<SB-SYS:FD-STREAM for "a socket" {B8E0AA1}></div>
<div> #(97 108 121 116 105 99 115 62 10 32 32 102 49 50 51 52 53 54 55 56 57 48</div><div>. . . long array of data</div><div>)</div><div> 0</div><div> 8191</div><div> NIL)</div><div>10: (SB-IMPL::ANSI-STREAM-READ-SEQUENCE</div>
<div> #(97 108 121 116 105 99 115 62 10 32 32 102 49 50 51 52 53 54 55 56 57 48</div><div>. . . long array of data</div><div>)</div><div> #<SB-SYS:FD-STREAM for "a socket" {B8E0AA1}></div><div> 0</div>
<div> 8191)</div><div>11: (READ-SEQUENCE</div><div> #(97 108 121 116 105 99 115 62 10 32 32 102 49 50 51 52 53 54 55 56 57 48</div><div>. . . long array of data</div><div>)</div><div> #<SB-SYS:FD-STREAM for "a socket" {B8E0AA1}>)[:EXTERNAL]</div>
<div>12: ((SB-PCL::FAST-METHOD TRIVIAL-GRAY-STREAMS:STREAM-READ-SEQUENCE</div><div> (FLEXI-STREAMS:FLEXI-INPUT-STREAM T T T))</div><div> #<unavailable argument></div><div> #<unavailable argument></div>
<div> #<unavailable argument></div><div> #<unavailable argument></div><div> #<unavailable argument></div><div> #<unavailable argument>)[:EXTERNAL]</div><div>13: ((LAMBDA</div><div> (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0. SB-PCL::.ARG1.</div>
<div> SB-PCL::.ARG2. SB-PCL::.ARG3. SB-INT:&MORE</div><div> SB-PCL::.DFUN-MORE-CONTEXT. SB-PCL::.DFUN-MORE-COUNT.))</div><div> #<unused argument></div><div> #<unused argument></div>
<div> #<FLEXI-STREAMS:FLEXI-IO-STREAM {B8EA781}></div><div> #(97 108 121 116 105 99 115 62 10 32 32 102 49 50 51 52 53 54 55 56 57 48</div><div>. . . long array of data</div><div>)</div><div> 0</div><div>
8191</div><div> -307111303</div><div> 0)</div><div>14: (READ-SEQUENCE</div><div> #(97 108 121 116 105 99 115 62 10 32 32 102 49 50 51 52 53 54 55 56 57 48</div><div>. . . long array of data</div><div>)</div>
<div> #<FLEXI-STREAMS:FLEXI-IO-STREAM {B8EA781}>)[:EXTERNAL]</div><div>15: ((SB-PCL::FAST-METHOD RUNES::XSTREAM-UNDERFLOW (RUNES:XSTREAM))</div><div> #<unavailable argument></div><div> #<unavailable argument></div>
<div> #<RUNES:XSTREAM [main document :MAIN NIL]>)</div><div>16: (CXML::READ-NAME-TOKEN #<unavailable argument>)</div><div>17: (CXML::READ-TAG-2</div><div> #S(CXML::ZSTREAM</div><div> :TOKEN-CATEGORY :SEEN-<</div>
<div> :TOKEN-SEMANTIC NIL</div><div> :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN NIL]>))</div><div> #<RUNES:XSTREAM [main document :MAIN NIL]></div><div> :STAG)</div><div>18: (CXML::FIX-SEEN-<</div>
<div> #S(CXML::ZSTREAM</div><div> :TOKEN-CATEGORY :SEEN-<</div><div> :TOKEN-SEMANTIC NIL</div><div> :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN NIL]>)))</div><div>19: (CXML::P/DOCUMENT</div>
<div> #S(CXML::ZSTREAM</div><div> :TOKEN-CATEGORY :SEEN-<</div><div> :TOKEN-SEMANTIC NIL</div><div> :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN NIL]>))</div><div> #<RUNE-DOM::DOM-BUILDER {B8EB0B9}>)[:EXTERNAL]</div>
<div>20: ((LAMBDA (CXML::ZSTREAM))</div><div> #S(CXML::ZSTREAM</div><div> :TOKEN-CATEGORY :SEEN-<</div><div> :TOKEN-SEMANTIC NIL</div><div> :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN NIL]>)))</div>
<div>21: (CXML::CALL-WITH-ZSTREAM</div><div> #<CLOSURE (LAMBDA #) {B8EE055}></div><div> #S(CXML::ZSTREAM</div><div> :TOKEN-CATEGORY :SEEN-<</div><div> :TOKEN-SEMANTIC NIL</div><div> :INPUT-STACK (#<RUNES:XSTREAM [main document :MAIN NIL]>)))</div>
<div>22: (CXML::PARSE-XSTREAM</div><div> #<RUNES:XSTREAM [main document :MAIN NIL]></div><div> #<RUNE-DOM::DOM-BUILDER {B8EB0B9}>)[:EXTERNAL]</div><div>23: (ROUNDS-WEB::ANALYTICS-SERVICE) ;;; This is my service I've posted the sources next</div>
<div>24: ((SB-PCL::FAST-METHOD HUNCHENTOOT:HANDLE-REQUEST</div><div> (HUNCHENTOOT:ACCEPTOR HUNCHENTOOT:REQUEST))</div><div> #<unavailable argument></div><div> #<unavailable argument></div><div> #<HUNCHENTOOT:ACCEPTOR (host *, port 8080)></div>
<div> #<HUNCHENTOOT:REQUEST {B8E8A11}>)</div><div>25: ((SB-PCL::FAST-METHOD HUNCHENTOOT:PROCESS-REQUEST (T))</div><div> #<unavailable argument></div><div> #<unavailable argument></div><div> #<HUNCHENTOOT:REQUEST {B8E8A11}>)</div>
<div>26: ((SB-PCL::FAST-METHOD HUNCHENTOOT:PROCESS-CONNECTION</div><div> (HUNCHENTOOT:ACCEPTOR T))</div><div> #<unavailable argument></div><div> #<unavailable argument></div><div> #<HUNCHENTOOT:ACCEPTOR (host *, port 8080)></div>
<div> #<USOCKET:STREAM-USOCKET {B8E0B31}>)</div><div>27: ((SB-PCL::FAST-METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND</div><div> (HUNCHENTOOT:ACCEPTOR T))</div><div> #<unavailable argument></div><div>
#S(SB-PCL::FAST-METHOD-CALL</div><div> :FUNCTION #<FUNCTION #></div><div> :PV NIL</div><div> :NEXT-METHOD-CALL NIL</div><div> :ARG-INFO (2))</div><div> #<HUNCHENTOOT:ACCEPTOR (host *, port 8080)></div>
<div> #<USOCKET:STREAM-USOCKET {B8E0B31}>)</div><div>28: ((LAMBDA ()))</div><div>29: ((FLET #:WITHOUT-INTERRUPTS-BODY-[BLOCK353]358))</div><div>30: ((FLET SB-THREAD::WITH-MUTEX-THUNK))</div><div>31: ((FLET #:WITHOUT-INTERRUPTS-BODY-[CALL-WITH-MUTEX]267))</div>
<div>32: (SB-THREAD::CALL-WITH-MUTEX</div><div> #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK) {B6C77205}></div><div> #S(SB-THREAD:MUTEX</div><div> :NAME "thread result lock"</div><div> :%OWNER #<SB-THREAD:THREAD "Hunchentoot worker (client: <a href="http://127.0.0.1:39378">127.0.0.1:39378</a>)" RUNNING {B8E2391}></div>
<div> :STATE 1)</div><div> #<SB-THREAD:THREAD "Hunchentoot worker (client: <a href="http://127.0.0.1:39378">127.0.0.1:39378</a>)" RUNNING {B8E2391}></div><div> T)</div><div>33: ((LAMBDA ()))</div>
<div>34: ("foreign function: #x8066E3B")</div><div>35: ("foreign function: #x8052ABD")</div><div>36: ("foreign function: #x805DC00")</div><div>37: ("foreign function: #xB7FB696E")</div>
<div><br></div><div>[2011-07-06 14:20:27 [ERROR]] Error while processing connection: #<SB-SYS:FD-STREAM for "a socket" {B8E0AA1}> is closed</div></div><div><br></div><div><br></div><div>And here's the code for that service:</div>
<div><br></div><div><div>(in-package :rounds-web)</div><div><br></div><div>(defun split-no-last (subject by)</div><div> (loop with last = 0</div><div> for i = (position by subject :start last)</div><div> if i</div>
<div> collect (subseq subject last i) into parts and</div><div> do (setf last (1+ i))</div><div> else</div><div> when (> (1- (length subject)) last)</div><div> collect (subseq subject last) into parts</div>
<div> end and</div><div> return parts</div><div> end))</div><div><br></div><div>(defun time-value (raw-value)</div><div> (let* ((pos (position #\. raw-value))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (result (list (subseq raw-value 0 pos)))</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (raw-length (length raw-value)))</div><div> (if (< pos raw-length)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(append result (list (subseq raw-value (1+ pos) raw-length)))</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>result)))</div><div><br></div><div>(defun parse-name (attribute)</div><div> ;; *round*, *category* and *event-type* are hash tables defined elsewhere</div>
<div> `(,(gethash (subseq attribute 0 1) *round*)</div><div> ,(gethash (subseq attribute 1 3) *category*)</div><div> ,(gethash (subseq attribute 3) *event-type*)))</div><div><br></div><div>(defun print-attribute (stream attribute val)</div>
<div> (format stream "Event: Round ~a | Category ~a | Type ~a~&"</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (first attribute)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (second attribute)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (third attribute))</div><div> (loop for v in val</div><div> for split = (time-value v)</div><div> for time = (first split)</div><div> for value = (if (> (length split) 1) (second split) nil)</div>
<div> do (format stream " Time: ~a, Value: ~a~&" time value)))</div><div><br></div><div>(defun save-parsed-events (xml)</div><div> (with-open-file (stream "./analytics.log"</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> :direction :output</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> :if-exists :supersede)</div><div> (loop for node across (dom:child-nodes xml)</div><div> do (when (eq (dom:node-type node) :element)</div><div>
<span class="Apple-tab-span" style="white-space:pre"> </span> (format stream "VideoSessionId: ~a =========================================~&"</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (subseq (dom:node-name node) 1))</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (when (dom:attributes node)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (loop with attributes = (dom:attributes node)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> for n from 0 upto (1- (dom:length attributes))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> for attribute = (dom:item attributes n)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> do (print-attribute </div><div><span class="Apple-tab-span" style="white-space:pre"> </span> stream (parse-name (dom:name attribute))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (split-no-last</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (dom:get-attribute node (dom:name attribute)) #\,))))))))</div><div><br></div><div>(defun analytics-service ()</div><div> (save-parsed-events</div>
<div> (dom:first-child</div><div> (cxml:parse-stream </div><div> (hunchentoot:raw-post-data</div><div> :request hunchentoot:*request*</div><div> :want-stream t)</div><div> (cxml-dom:make-dom-builder)))))</div>
</div><div><br></div><div>This code isn't meant for production, all it does it mocks a real service which is meant to do the same thing so I could use it for testing, yet, I'd of course like it to work :) </div><div>
Please, if you have anything to suggest, I'd be very happy to hear!</div><div><br></div><div>Thanks!</div><div><br></div><div>Oleg</div></div>