Open dy93 opened 8 years ago
Hey! Here is update: I found that the problem was remove stream too early, this is a simpler code to reproduce the situation:
var spdy = require('spdy'),
fs = require('fs');
var options = {
key: fs.readFileSync(__dirname + '/my.key'),
cert: fs.readFileSync(__dirname + '/my.crt'),
spdy: {
protocols: ['h2'],
plain: false,
connection: {
windowSize: 1024 * 1024,
autoSpdy31: false
}
}
};
var server = spdy.createServer(options, function(req, res) {
res.spdyStream.connection.end(); // send GOAWAY frame
setTimeout(function(){
res.writeHead('200');
res.end('hello'); // client should get this "hello"
}, 1000);
});
server.listen(443);
when I visit the server from the browser, I just get connection closed unexpectedly.
If I comment out self.on('_streamDrain', self._onStreamDrain);
in Connection.prototype._goaway
in spdy-transport/lib/spdy-transport/connection.js, I can get the "hello" perfectly
The problem was that we remove stream too early (with adding DEBUG=* when executing server, I found that spdy remove the stream just after sending DATA frame which contains "hello" but before the DATA frame which contains "END_STREAM" flag)
Since DATA frame which containing "END_STREAM" cannot be delivered to browser before tcp connection closed, browser abort any DATA frame received previously.
Please solve this problem, thank you!
@dy93 could you check if this is still a issue?
thanks for your help to add public api for getting connection object in issue 238
but my problem still not solved. the file download process started before GOAWAY frame should success in the end. here's the sample code to explain my problem:
to run this sample, you should generate a large file named
large.bin
(the size is depends on your network speed, it should be large enough that can not be complete downloaded in 2 seconds)get file
link, and the download process startbut i just get "network error" in my chrome, and download process failed I think it may be a problem that server lake of "END_STREAM" flag in the last DATA frame ?
here is my environment: node-spdy: 3.2.0 chrome: 47.0.2526.111 m