سؤال

I just wanted to try out SPDY using the node package "node-spdy".

My javascript:

EDIT: Now the script includes informations about certificates. I took them from the twitlog test application.

var spdy = require('spdy'),
    fs = require('fs');

var options = {
    key: fs.readFileSync(__dirname + '/keys/spdy-key.pem'),
    cert: fs.readFileSync(__dirname + '/keys/spdy-cert.pem'),
    ca: fs.readFileSync(__dirname + '/keys/spdy-csr.pem')
};

var spdy = require('spdy');

var server = spdy.createServer({}, function(req, res) {
    console.log('Send response...');
    res.writeHead(200, {
        "Content-Type": "text/plain"
    });
    res.write("Hello World!\n");
    res.end();
    console.log('Response has been sended.');
});

server.listen(3000);

My problem: The callback function is never executed, respectively node never logs "Send response..." or "Response has been sended.". I just get an empty response, but node.js doesn't throw an exeption:

Fehler 324 (net::ERR_EMPTY_RESPONSE)

My server-side config: I use node.js (version 0.7.6) and node-spdy (commit eafd9c9fdd) under Windows Se7en.

My client-side configuration: I use a chromium build as browser in order to test spdy out. During my tests I don't use SSL, so I had to change my configuration. That's what you can find under about:net-internals/#spdy:

==SPDY Status==

SPDY Enabled:               true
Use Alternate Protocol:     false
Force SPDY Always:          true
Force SPDY Over SSL:        false
Next Protocols:

My client-side debug stuff: The chromium debugging service about:net-internals/#tests tells me:

Result  Experiment                      Error                   Time (ms)
FAIL    Fetch http://localhost:3000/
        Don't use any proxy             EMPTY_RESPONSE (-324)   3022

        Fetch http://localhost:3000/
        Use system proxy settings       ?                       ?

EDIT: Since I added certificate infomation, the client-side debugging information changed a bit. Here's the newest one:

Result  Experiment                      Error                   Time (ms)
FAIL    Fetch https://localhost:3000/
        Don't use any proxy             ABORTED (-3)            9

FAIL    Fetch https://localhost:3000/
        Use system proxy settings       ABORTED (-3)            300489

FAIL    Fetch https://localhost:3000/
        Use Firefox's proxy settings    ABORTED (-3)            4

FAIL    Fetch https://localhost:3000/
        Use system proxy settings       ABORTED (-3)            300438

My server-side debug stuff: That's what the built-in node debugger tells me when I receive a request:

EDIT: The server-side debug stuff would not change, even if I add certificate information to the scripts.

debug>n
break in net.js:865
 863
 864 function onconnection(clientHandle) {
 865   var handle = this;
 866   var self = handle.socket;
 867
debug>
break in net.js:866
 864 function onconnection(clientHandle) {
 865   var handle = this;
 866   var self = handle.socket;
 867
 868   debug('onconnection');
debug>
break in net.js:868
 866   var self = handle.socket;
 867
 868   debug('onconnection');
 869
 870   if (!clientHandle) {
debug>
break in net.js:870
 868   debug('onconnection');
 869
 870   if (!clientHandle) {
 871     self.emit('error', errnoException(errno, 'accept'));
 872     return;
debug>
break in net.js:875
 873   }
 874
 875   if (self.maxConnections && self.connections >= self.maxConnections) {
 876     clientHandle.close();
 877     return;
debug>
break in net.js:880
 878   }
 879
 880   var socket = new Socket({
 881     handle: clientHandle,
 882     allowHalfOpen: self.allowHalfOpen
debug>
break in net.js:884
 882     allowHalfOpen: self.allowHalfOpen
 883   });
 884   socket.readable = socket.writable = true;
 885
 886   socket.resume();
debug>
break in net.js:886
 884   socket.readable = socket.writable = true;
 885
 886   socket.resume();
 887
 888   self.connections++;
debug>
break in net.js:888
 886   socket.resume();
 887
 888   self.connections++;
 889   socket.server = self;
 890
debug>
break in net.js:889
 887
 888   self.connections++;
 889   socket.server = self;
 890
 891   ;
debug>
break in net.js:892
 890
 891   ;
 892   self.emit('connection', socket);
 893   socket.emit('connect');
 894 }
debug>
break in net.js:893
 891   ;
 892   self.emit('connection', socket);
 893   socket.emit('connect');
 894 }
 895
debug>
break in net.js:894
 892   self.emit('connection', socket);
 893   socket.emit('connect');
 894 }
 895
 896
debug>

My question: I just wanna return a simple text message to the client using SPDY. How can I do that using node.js? - If you need some more details, please tell me. Thanks for your answers.

هل كانت مفيدة؟

المحلول

Turn SSL back on. SPDY won't work without it.

نصائح أخرى

ERR_EMPTY_RESPONSE means that Chromium was able to connect to the socket, but received an empty response. In all likelihood, that points to a server configuration issue, especially since the callback is never invoked. Chris Strom (node-spdy author) would probably be happy to help you here.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top