0

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.

fridojet
  • 1,276
  • 3
  • 15
  • 29
  • I think I just read something interesting in a [comment](http://japhr.blogspot.com/2012/04/edge-spdy-nodejs-and-expressjs.html?showComment=1335207922979#c4966358242271584919) written by Storm: `It is not possible to run node-spdy without SSL.` I'll try to find out more about that, or does anybody of you know something about that fact? – fridojet May 14 '12 at 15:09
  • Now I use SSL with the certificates of the example application. But there are still the same problems. – fridojet May 14 '12 at 16:37

2 Answers2

1

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.

William Chan
  • 758
  • 7
  • 8
  • That's what I thought too. I know about Chris Strom, but I didn't want to write him a mail because I didn't want to bug him by personal help requests. Or is it okay for him to ask personally? Or is there another way to contact him nicely? – fridojet May 14 '12 at 14:56
0

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

Tom van der Woerdt
  • 29,532
  • 7
  • 72
  • 105
  • The SPDY whitepaper tells me, `The results show a speedup over HTTP of 27% - 60% in page load time over plain TCP (without SSL), and 39% - 55% over SSL.` That means, that plain TCP is also possible, doesn't it? – fridojet May 13 '12 at 19:48
  • TLS/SSL is not *required* for SPDY. See http://stackoverflow.com/questions/6304217/spdy-without-tls/7628644#7628644 for a more detailed explanation. – William Chan May 13 '12 at 19:56
  • Webbrowsers won't allow you to use SPDY without SSL, unless you explicitly force them to. Allowing the developer to turn off SSL is only to make debugging easier via tools such as Wireshark. Also, @fridojet, the part you quoted compares SPDY against "the old" http:// and https://. – Tom van der Woerdt May 14 '12 at 13:02
  • But StartCom won't sign localhost, would it? So as long as I just do local internal test, I think I have to use plain TCP or I have to sign myself. – fridojet May 14 '12 at 14:52
  • Yeah, just sign your own certificates for testing. Nothing wrong with that. – Tom van der Woerdt May 14 '12 at 15:55
  • @TomvanderWoerdt In order to stay simple, I just used the certifictes of the node-spdy test application called twitlog. I just edited the information in my question about that topic. But even if I use HTTPS, there are still some problems. – fridojet May 14 '12 at 18:51
  • @TomvanderWoerdt The problems nearly stayed the same. I changed the text of my questions in order to describe my "new" problems. But, for example, the results of the node.js debugging tool stayed the same as when I didn't use certificates. – fridojet May 16 '12 at 09:10
  • One detail I maybe should add: I use the certificates of the spdy-node example application called twitlog and I teached my chromium to accept them. – fridojet May 16 '12 at 09:13
  • It would really help a lot to have the information from the SPDY tab in `about:net-internals` instead of other tabs. Also make sure you open the normal version of Chrome and don't start it with any SPDY-related CLI switches. – Tom van der Woerdt May 16 '12 at 09:44
  • @TomvanderWoerdt In order to not make SSL necessary, I created a new chromium profile and I open it with the following flags: `--user-data-dir=Webtest --use-spdy=no-ssl` – fridojet May 16 '12 at 12:16
  • @TomvanderWoerdt `about:net-internals/#spdy` holds three sections. I copy'n'pasted the `SPDY status` section into the text of my question - you can find it at the `My client-side configuration` section. The sections `SPDY sessions` and `Alternate Protocol Mappings` are empty, or more precisely their content is `None`. – fridojet May 16 '12 at 12:22
  • @TomvanderWoerdt If it's a good idea, then I will test SPDY without command line flags. I'll post the results here. – fridojet May 16 '12 at 12:24
  • Fine, now it's working, i'm never ever going to use any command line flags again ...... Yeah!! I'll post some details later on for those who have the same suspicious problems. @TomvanderWoerdt Thanks a lot. – fridojet May 16 '12 at 12:26
  • Those Chromium flags are really for SPDY developers (such as myself) only, not users (such as you). You really shouldn't be touching those ;-) – Tom van der Woerdt May 16 '12 at 12:46