[racket] bug?

From: Jordan Schatz (jordan at noionlabs.com)
Date: Thu Jul 7 12:55:14 EDT 2011

> Looks like some issue at the ssl level.  If I run this code:
> 
>   #lang racket
>   (require openssl/mzssl)
>   (define-values [i o] (ssl-connect "mtgox.com" 443 'sslv2-or-v3))
>   (fprintf o "GET /code/data/ticker.php HTTP/1.0\r\nHost: mtgox.com\r\n\r\n")
>   (close-output-port o)
>   (let loop ()
>     (define c (read-char i))
>     (unless (eof-object? c) (write-char c) (flush-output) (loop)))
> 
> I see the same problem.  Similarly for other bogus inputs (like a bad
> path or a bogus HTTP version) -- *but*, if I drop the "HTTP/1.0", or
> even change it to "HTTP", then instead of hanging I get
> 
>   tcp-read: error reading (Connection reset by peer; errno=104)

Solved. Its a "bug" in mtgox.com not in Racket. mtgox.com has had alot of
problems with DDOS, so if anything in the request is out of the ordinary
they try to hang the client. What was out of the ordinary in what we
where sending was that it didn't specify a user agent.

#lang racket
(require net/url)
(call/input-url
 (string->url "https://mtgox.com/code/data/ticker.php")
 get-pure-port
 (lambda (ip)
   (copy-port ip (current-output-port))
   (newline))
 (list "User-Agent: racket"))

Works like a charm...

Shalom,
Jordan


On Mon, Jun 27, 2011 at 03:19:36AM -0400, Eli Barzilay wrote:
> 8 hours ago, Jordan Schatz wrote:
> > I'm not sure if this is considered a bug in racket or in the SSL
> > implementation at mtgox.com.  The mtgox url does work fine for me
> > via curl/wget etc.  As far as I can tell when racket tries to
> > retrieve the mtgox url everything starts off fine: the TLS handshake
> > happens, then the request is sent and application data retrieved,
> > but after that it just hangs.
> 
> Looks like some issue at the ssl level.  If I run this code:
> 
>   #lang racket
>   (require openssl/mzssl)
>   (define-values [i o] (ssl-connect "mtgox.com" 443 'sslv2-or-v3))
>   (fprintf o "GET /code/data/ticker.php HTTP/1.0\r\nHost: mtgox.com\r\n\r\n")
>   (close-output-port o)
>   (let loop ()
>     (define c (read-char i))
>     (unless (eof-object? c) (write-char c) (flush-output) (loop)))
> 
> I see the same problem.  Similarly for other bogus inputs (like a bad
> path or a bogus HTTP version) -- *but*, if I drop the "HTTP/1.0", or
> even change it to "HTTP", then instead of hanging I get
> 
>   tcp-read: error reading (Connection reset by peer; errno=104)
> 
> -- 
>           ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
>                     http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.