Error after retrieving page: invalid stream #4

inkel opened this Issue Oct 6, 2011 · 6 comments


None yet
3 participants

inkel commented Oct 6, 2011


I've been trying to run the sample server with Ruby 1.9.2 and 1.9.3, but I'm getting the following error after retrieving the page contents:

[:SPDY, :connection_closed]
[:SPDY, :connection_closed]
[:SPDY_HEADERS, {"accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "accept-charset"=>"ISO-8859-1,utf-8;q=0.7,*;q=0.3", "accept-encoding"=>"gzip,deflate,sdch", "accept-language"=>"en-US,en;q=0.8", "cache-control"=>"max-age=0", "host"=>"localhost:10000", "method"=>"GET", "scheme"=>"https", "url"=>"/", "user-agent"=>"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.899.0 Safari/535.6", "version"=>"HTTP/1.1"}]
[:SPDY, :sent, :SYN_REPLY]
[:SPDY, :sent, :DATA]
[:SPDY, :sent, :DATA_FIN]
[:SPDY, :connection_closed]
/home/inkel/.rvm/gems/ruby-1.9.2-p290/gems/spdy-0.0.2/lib/spdy/compressor.rb:35:in `inflate': invalid stream (RuntimeError)
        from /home/inkel/.rvm/gems/ruby-1.9.2-p290/gems/spdy-0.0.2/lib/spdy/parser.rb:33:in `unpack_control'
        from /home/inkel/.rvm/gems/ruby-1.9.2-p290/gems/spdy-0.0.2/lib/spdy/parser.rb:57:in `try_parse'
        from /home/inkel/.rvm/gems/ruby-1.9.2-p290/gems/spdy-0.0.2/lib/spdy/parser.rb:11:in `<<'
        from spdy_server_cm.rb:36:in `receive_data'
        from /home/inkel/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
        from /home/inkel/.rvm/gems/ruby-1.9.2-p290/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
        from spdy_server_cm.rb:44:in `<main>'

The line that's triggering the error is:

result = FFI::Zlib.inflate(zstream, FFI::Zlib::Z_SYNC_FLUSH)
raise "invalid stream" if result != FFI::Zlib::Z_NEED_DICT

I checked the value of result and it's -3, that is FFI::Zlib::Z_DATA_ERROR. Any ideas what it might be? Thanks for your time and good work!

PS: IIRC, shouldn't only check the first time to see if a dictionary is needed, and then, once the stream is properly setup just use it? I've read the SPDY book but I'm a bit confused by this.


eee-c commented Oct 6, 2011

This is a dupe of issue #2, which was resolved in issue #3 :)

@igrigorik you should probably push a new version up to with the fix.

inkel commented Oct 6, 2011

@eee-c thanks! I'll clone the project then and try it again


eee-c commented Oct 6, 2011

@inkel zlib is a funny little library. The only way to set the dictionary is to call inflate() and then set the dictionary if the return value is NEED_DICT. So every time that you call inflate() you need a NEED_DICT check. It's ugly, but it's C code, so what else would you expect? ;-)

Regardless, you are correct, the raise in this case was inappropriate -- Carson's fix in #3 cleaned that up.

Thanks for reading the SPDY Book!

inkel commented Oct 6, 2011

@eee-c I really liked the book. I'm still have to send my feedback, but overall, great reading.


igrigorik commented Oct 6, 2011

0.0.3 should be live now. :)

@igrigorik igrigorik closed this Oct 6, 2011

inkel commented Oct 6, 2011


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment