[Chicken-users] with-input-from-request does not close SSL socket
I use the http-client egg to send queries to a HTTPS server: (with-input-from-request https://server/some/url; search (lambda () (ssax:xml-sxml (current-input-port) '() For every connection I get an CLOSE_WAIT with 38 bytes in the receive queue: Proto Recv-Q Send-Q Local Address Foreign Address State tcp 38 0 2.11.152.42:45237 10.100.26.82:443 CLOSE_WAIT This looks to me as if with-input-from-request fails to close the socket, which is probably a bug. As a work around I need a way to close the socket. How can I access the socket to force closing it? I tried to use close-connection! this way: (let ((result (with-input-from-request uri search (lambda () (ssax:xml-sxml (current-input-port) '()) (close-connection! uri) result)) But this does not have any effect. I can see the sockets leeking in the proc filesystem. After start I have two sockets: $ ls -nl /proc/23236/fd total 0 lrwx-- 1 31338 91 64 Dec 14 15:10 0 - socket:[3185978] lr-x-- 1 31338 91 64 Dec 14 15:10 3 - /myprogram.scm lrwx-- 1 31338 91 64 Dec 14 15:10 4 - socket:[3185977] And during each client request I get a new socket. After 3 connections I have 5 sockets: $ ls -nl /proc/23236/fd total 0 lrwx-- 1 31338 91 64 Dec 14 15:10 0 - socket:[3185978] lr-x-- 1 31338 91 64 Dec 14 15:10 3 - /myprogram.scm lrwx-- 1 31338 91 64 Dec 14 15:10 4 - socket:[3185977] lrwx-- 1 31338 91 64 Dec 14 15:11 5 - socket:[3186523] lrwx-- 1 31338 91 64 Dec 14 15:11 7 - socket:[3186528] lrwx-- 1 31338 91 64 Dec 14 15:11 8 - socket:[3186530] How can I stop this? I have the following versions: 4.7.0.3-st openssl ... version: 1.6.1 http-client . version: 0.5 intarweb version: 0.7 ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] with-input-from-request does not close SSL socket
On Wed, Dec 14, 2011 at 03:16:57PM +0100, obscurolocon...@googlemail.com wrote: I use the http-client egg to send queries to a HTTPS server: (with-input-from-request https://server/some/url; search (lambda () (ssax:xml-sxml (current-input-port) '() For every connection I get an CLOSE_WAIT with 38 bytes in the receive queue: Proto Recv-Q Send-Q Local Address Foreign Address State tcp 38 0 2.11.152.42:45237 10.100.26.82:443 CLOSE_WAIT This looks to me as if with-input-from-request fails to close the socket, which is probably a bug. This is expected. The http-client egg tries to use HTTP/1.1 if it's supported and re-use the connection to pipeline requests. This saves on TCP/IP handshake overhead and in the case of SSL saves even more overhead for the SSL negotiation. As a work around I need a way to close the socket. How can I access the socket to force closing it? I tried to use close-connection! this way: (let ((result (with-input-from-request uri search (lambda () (ssax:xml-sxml (current-input-port) '()) (close-connection! uri) result)) But this does not have any effect. Hm, that ought to work. Perhaps there's a bug in the openssl egg. I'll have a look at it later. Cheers, Peter -- http://sjamaan.ath.cx -- The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music. -- Donald Knuth ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] with-input-from-request does not close SSL socket
2011/12/14 Peter Bex peter@xs4all.nl: Hm, that ought to work. Perhaps there's a bug in the openssl egg. Yes it is a openssl problem. I was able to solve the problem by replacing http-client with the following code: (define (https-1.0-post host path query thunk) (let-values (((input output) (ssl-connect host 443))) (handle-exceptions exn (begin (close-input-port input) (close-output-port output) (abort exn)) (let ((body (form-urlencode query separator: ))) (write-request (make-request major: 1 minor: 0 uri: (uri-reference path) port: output method: 'POST headers: (headers `((host (,host . #f)) (connection close) (content-type application/x-www-form-urlencoded) (content-length ,(string-length body)) (display body output) (flush-output output) (let ((result (thunk (read-response input (close-input-port input) (close-output-port output) result) Without explicitly closing the two ports, I got the same socket leaking. ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Strange SSAX parse errors
I have a threaded server making SSL connections to another server and parsing the HTTP response with SSAX. Sometimes I get strange exceptions in my logs: [GIMatch] broken for (END . employee) while expecting ENDresuoyee [GIMatch] broken for (END . line-manager) while expecting ENDresult-sager [GIMatch] broken for (END . result-seger) while expecting ENDline-manager [GIMatch] broken for (END . resloyee) while expecting ENDemployee [GIMatch] broken for (END . 203ult-set) while expecting ENDresult-set [GIMatch] broken for (END . result-setlationship) while expecting ENDworking-relationship [GIMatch] broken for (END . 2esult-set) while expecting ENDresult-set [GIMatch] broken for (END . resuoyee) while expecting ENDemployee [GIMatch] broken for (END . result-setla) while expecting ENDline-manager The error message itself seems to be broken, too. The error occurs in the following function: (define/e exn (parse-xml xml) (let ((id (+ 10 (random 90 (logger prio/err Error while parsing XML id : (format-exception exn)) (let ((port (open-output-file (fmt #f /tmp/people-bridge. id .xml (display xml port) (flush-output port)) ;;(ssax:xml-sxml (open-input-string xml) '()) #f ) (ssax:xml-sxml (open-input-string xml) '())) The macro define/e is only a wrapper for handle-exceptions: (define-syntax define/e (syntax-rules () ((_ exn (arg ...) handler body ...) (define (arg ...) (handle-exceptions exn handler (begin body ...)) The error occurs in the ssax:xml-sxml function. My first idea was, that the XML is actually broken. So I stored the XML in a temp file to be able to analyze it. But there is everything fine with the XML data. After that I changed only one single line in my code: instead of returning #f in the exception handler I ran the XML parser once again. And than it works. But how can this be? How can the call to ssax:xml-sxml in the exception handler be successful if it fails just a moment before on the same data? ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] PDF egg
Hello! Does anyone know how could I add a new font when using de PDF egg? I've seen it implements only some types of font (Courier, Helvetica, Symbols, etc.) and pdf-font.scm has a procedure called 'add-font-info-from-file', but it is not accessible to the user. Thanks, Arthur ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users