Thursday, April 19, 2012

Edge SPDY, Node.js, and Express.js

‹prev | My Chain | next›

I am slowly coming to the conclusion that this may not be the best time to issue a 1.1 edition of SPDY Book. Much of the new hotness that is node-spdy is in limbo until the unstable 0.7 node.js becomes stable 0.8. I almost have a handle on that except for express.js, the pleasant HTTP resource-oriented application server. The current 2.0 series will work with edge node-spdy, but not 0.7/0.8 node.js. For 0.8 node.js, the 3.0 alpha of express.js is imminent—only it does not play well with node-spdy.

All of these moving parts have me thinking that a more modest SPDY Book update might be the better part of valor. But I am not quite ready to give up. First, I would like to have a go at getting edge node-spdy and edge express.js working together.

The latest node-spdy does a rather elegant thing when creating SPDY-sized servers—it accepts an optional class argument that can be used to decorate server-like objects. This is specifically used to create express.js instances as I found last night:
var app = spdy.createServer(express.HTTPSServer, options);
The problem presented by edge express.js is that there is no express.HTTPSServer class anymore. In particular, the new express.application is more of a mixin than a proper class.

The answer (hopefully) is that node-spdy also works with HTTP server objects, which is what the express() function ought to return in 3.0. I have my forks of express.js and connect.js (for middleware) checked out locally. I have to modify the package.json for each to be compatible with 0.7:
{
  "name": "express",
  "description": "Sinatra inspired web development framework",
  // ...
  "engines": { "node":">= 0.5.0 < 0.9.0" }
}
With that, I can install globally and use the resultant generator to get started on an express3 application:
➜  tmp  npm install -g ~/repos/express/ ~/repos/connect
➜  tmp  express express3-spdy-test
➜  tmp  cd express3-spdy-test
➜  express3-spdy-test  npm install ~/repos/express ~/repos/connect ~/repos/node-spdy
➜  express3-spdy-test  npm install jade
I also copy the SSL keys from my 2.0 test application:
➜  express3-spdy-test  mkdir keys
➜  express3-spdy-test  cp ../express-spdy-test/keys/* keys 
➜  express3-spdy-test  ls keys 
spdy-cert.pem  spdy-csr.pem  spdy-key.pem
I can start up the generated express 3.0 app:
➜  express3-spdy-test  node app
Express server listening on port 3000
Pointing the browser at that site, I get the expected default homepage:


Next, I need an SSL version of the site. For that I change the http.createServer() to the https equivalent in the application app.js file:
// ...
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')
};

https.createServer(options, app).listen(3000);
After restarting, I can now access the default express.js site over SSL:


Now for the moment of truth: switching to node-spdy. I add spdy to the list of required packages and replace the https.createServer with the node-spdy equivalent:
var express = require('express')
  , routes = require('./routes')
  , http = require('http')
  , https = require('https')
  , spdy = require('spdy')
  , fs = require('fs');

var app = express();

app.configure(function(){ /* ... */ });

app.get('/', routes.index);

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')
};

//https.createServer(options, app).listen(3000);
spdy.createServer(https.Server, options, app).listen(3000);
After starting the server, I can again access the homepage over SSL, but this time, when I check the SPDY tab in Chrome's chrome://net-internals, I have SPDY!
SPDY_SESSION_SYN_STREAM
--> flags = 1
--> 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: no-cache
    cookie: [value was stripped]
    host: localhost:3000
    method: GET
    pragma: no-cache
    scheme: https
    url: /
    user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.8 (KHTML, like Gecko) Chrome/20.0.1105.0 Safari/536.8
    version: HTTP/1.1
--> id = 1
SPDY_SESSION_RECV_SETTING
--> flags = 1
--> id = 4
--> value = 100
SPDY_SESSION_SYN_REPLY
--> flags = 0
--> content-length: 277
    content-type: text/html; charset=utf-8
    status: 200 OK
    version: HTTP/1.1
    x-powered-by: Express
--> id = 1
...
Aw, man! That is nice. I was really worried that the new express.js would be incompatible, but clearly my worries were completely unfounded. Not only does it work, but it is really easy to configure and get running. Once again, kudos to Fedor Indunty for the very slick implementation.

Despite the ease with which I got all of this up and running, I am still in a bit of a bind with regards to including edge stuff like this in the updated book or sticking with express-spdy, which is clearly no longer needed. The former is a moving target and the latter is likely to be obsolete days after I put out the next edition of The SPDY Book. I think this suggests that minimal changes for now might be the best course of action, but I will sleep on it before making a decision.

If nothing else, the future of SPDY on node.js looks quite nice.


Day #361

87 comments:

  1. I followed your same steps, except in Windows, with node v0.7.8, but when I visit the URL in Chrome, net-internals doesn't list it as SPDY. What steps can I do to debug why Chrome isn't detecting it as SPDY session? Or isn't utilizing SPDY...

    ReplyDelete
    Replies
    1. Hrm... I suppose the next step is snooping the SSL handshake to see if the server really is advertising SPDY. Something like wireshark should do: http://japhr.blogspot.com/2012/04/express-spdy-on-old-openssl.html

      Delete
    2. Since I couldn't wireshark local, I installed node on my mac and worked between it and vm of windows on it. Only this time SPDY worked, so I'll have to do the same against my other physical machine to see deviations. Do you know with node-spdy, is it possible to run the server with out SSL? I would like to be able to capture the traffic and analyze with Wireshark without dealing with SSL encryption...

      Thanks for the suggestions!

      Delete
    3. It is not possible to run node-spdy without SSL. There was a fork a while back that had a go at enabling this, but it was never merged in and would not work well with all of the changes in version 1.0 and later.

      I wonder if it's possible that node-spdy does not work under windows...?

      Delete
  2. Can we use SPDY with HTTP ?? and not HTTPS ?

    ReplyDelete
  3. very interesting, good job and thanks for sharing such a good blog. Seo Services Delhi

    ReplyDelete
  4. very interesting, good job and thanks for sharing such a good blog. Youtube Mp3 Converter

    ReplyDelete
  5. I think it will be good if you start youtube channel about it, I will subscribe for your channel, other youtube subscribers you can get from here https://soclikes.com/

    ReplyDelete
  6. Thank you so much for this innovative post, keep it up for more valuable information. Visit Ogen Infosystem for professional Website Designing and SEO Services in Delhi, India.
    Top 5 Website Designing Company in India

    ReplyDelete
  7. Event management company professionals will tell you that strategizing for venue visitors is one thing and planning for virtual attendees is completely different. event marketing and planning a vendor fair

    ReplyDelete
  8. Great content & thanks for sharing. but do you want to know about the Entropay alternative

    ReplyDelete
  9. Kristen Ashleey is an Author, blogger, and one of the exceptional writers specialized in health and medical sector & also write about profile content. She is one of the founders of Online Health Mantra – the first ever healthcare platform ensuring health services reaching at every individual level.

    ReplyDelete
  10. But what makes Indonesia so great? Major cities like Jakarta, Bandung, Yogyakarta, and Surabaya, an impressive university system, and low taxes means the Sunshine country is ripe with opportunity for savvy business owners. Keep reading to learn more about why Indonesia could be the perfect spot to start your new business!

    ReplyDelete
  11. An investment property is a property that has been purchased for the sole purpose of generating income. Investment properties in Bali can produce a return on investment in the form of rental returns or capital growth. Capital growth occurs when the value of the property has increased over time

    ReplyDelete
  12. An investment property is a property that has been purchased for the sole purpose of generating income. Investment properties in Bali can produce a return on investment in the form of rental returns or capital growth. Capital growth occurs when the value of the property has increased over time

    ReplyDelete

  13. Website Developer Bali adalah seorang Freelancer Website Developer Bali, dia sangat menyukai hobbynya dalam menelusuri setiap blok yang Anda di internet. Dia memiliki banyak pengetahuan tentang Digital Marketing dan bagaimana penerapan dalam bisnis.

    ReplyDelete
  14. Hi My Name is Maria Hayden & I am technical blogger at Get Human Help, I majorly writes and shares blogs on troubleshooting tips for routers, printers, antivirus, emails, Operating Systems, and others. Related Blogs - Why Is My Comcast Email Not Working?What to do to fix Yahoo Mail Not Syncing With Gmail?, How to fix Yahoo mail not loading on iPhone?How Do I Talk To A Live Person At Verizon AT&T?, How To Fix Bellsouth Not Working In Android?, How can I Reset Charter Spectrum Email Password?

    ReplyDelete
  15. Hi My Name is Mary Thomas& I am technical blogger at Get Human Help, I majorly writes and shares blogs on troubleshooting tips for routers, printers, antivirus, emails, Operating Systems, and others.
    Related Blogs -

    How can I Reset Charter Spectrum Email Password?
    How To Fix Bellsouth Not Working In Android?
    Eliminate Yahoo Mail error code 80040902 with the easy steps!
    Know the ways to terminate HP Printer error 49.4c02

    ReplyDelete
  16. Last Journey is providing all types of services such as Chautha, Tehravin, Pandit,Asthi Visarjan , Cremation and all crematorium in bangalore
    , Mumbai, Kolkata, Bangalore, Pune, Hyderabad and Chandigarh.
    ice box for dead body Last Journey
    dead body transport by road ice box for dead body dead body freezer box pet cremation

    ReplyDelete
  17. On your place I would make a video how to do it and post it on youtube or tiktok. I usually get likes for my video from this site https://viplikes.net/ to make it more popular

    ReplyDelete
  18. Hi, I'm kimjolly. It's my initiative for learning in the field of Mandarin in online chinese course UAE. if you are keen interested in learning Feel free to visit my website also contact our 24*7 assistance for all query related to learning Mandarin.

    ReplyDelete
  19. for players who are familiar with gambling games, of course they are familiar with the name sbobet which is the largest online gambling agent and of course we are here as a sbobet agent for Indonesian players and have proven to be the best and can be trusted by the Indonesian people

    ReplyDelete
  20. virtual event platform Although most features will only be released in the fourth quarter or later, the opportunity to explore first-hand some features as part of Zoomtopia made it clear that the company is serious about investing in the B2B events space. business invitation, Verizon’s Acquires BlueJeans to Take Over Virtual Conference Industry and Cvent to Go Public via SPAC at $5B Valuation after Being Private for 4 Years

    ReplyDelete
  21. I like your blog post. It is quite informative and helpful. If you are looking to solve att email issues, then Open your AT&T Mail in a different web browser. For example, if you normally use Google Chrome, try Firefox. Verify that your browser accepts cookies. Then, clear your cookies and cache. You’ll find this info in your browser's Preferences, Settings, or Options menu. Enable JavaScript, and make sure it’s up to date. You’ll find it in your browser settings or options. Disable browser tools or add-ons to see if they’re causing issues with email access. To resolve ATT Email not Working, enable Adobe Flash Player, and make sure it’s up to date.

    ReplyDelete
  22. I like your blog. Thanks for the information. If you want to change yahoo password, then open Yahoo Mail and tap on the Yahoo Mail app icon. Now, tap on the three-dot menu that is available in the top-left corner of the screen or the search bar. To change Yahoo password, Tap on Manage Accounts. Search your account name in the signed-in account list that appears on your screen. Now, tap on Account info that is a link just below the name of the account. Then tap on Security Settings. Now enter the password. After that, tap on Change Password. Now tap on ‘I would rather change my password’. Create a new password in the ‘New Password’ text field and then re-type on the password field. Tap on Continue to change your Yahoo mail password.

    ReplyDelete
  23. Do you have your iPhone Insurance? If no then connect with the best Mobile Insurance Company and avoid unexpected expenses.

    ReplyDelete
  24. thanks for sharing a nice blog keep posting like https://duckcreektraining.com/

    ReplyDelete
  25. How to troubleshoot TurboTax Error 190?
    If you are facing the issue of TurboTax Error 190, and the file indicates one or more state returns. No need to get worry. Reach the experts at any time. The experts are available 24/7 for the help of the users.
    Related Blogs –
    Facebook Account Recovery
    How to Speak to a Live Person at TurboTax
    Verizon Email Not Working
    Gmail not receiving emails
    Can’t sign into Verizon Email
    Facebook Account is Temporarily Locked

    ReplyDelete
  26. thanks for sharing nice blog https://snowflakemasters.in/

    ReplyDelete
  27. Really an awesome blog. Informative and knowledgeable content. Keep sharing more stuff like this. Thank you.
    Data Science Course Training in Hyderabad
    Data Science Course Training Institute in Hyderabad

    ReplyDelete
  28. You can hire the best SEO Company in Ghaziabad that is PromoteDial for growing your online business. If you are not able to get more traffic and customers towards your website then we can be the right choice for you.

    ReplyDelete
  29. How to Install TurboTax Program Using the CD Drive?
    TurboTax is even though one of the best-ever tax-filing PC program and easy to install, yet, some users have been confused over how to install TurboTax with CD. So if you’re not able to install the program on your own using the CD drive, you can download the TurboTax program from the official website and install it on your PC.

    ReplyDelete
  30. Really your post was so nice and energetic I like your post regularly and i read your all post regularlly.Best UPSC Prelims Daily Quiz

    ReplyDelete
  31. If you are interested to get world class web design for your business then you need to connect with website design company in hyderabad that name is CSS Founder Private Limited.

    ReplyDelete
  32. List with Confidence Real Estate Company all of our agents are long time locals and experts in the local real estate market. Find out about them here.

    Real Estate Agents Near Me
    Gta Real Estate Market

    ReplyDelete
  33. Diesel Brothers offer different types of services, Truck and Trailer , Reefer, Truck Alignment, Roadside Assistance, and APU.

    Tire repair near me
    Gas near me

    ReplyDelete
  34. Very informative and interesting content. I have read many blog in days but your writing style is very unique and understanding. If you have read my articles then click below.

    himalayan salt lamp spiritual benefits
    himalayan salt spiritual benefits

    ReplyDelete
  35. Connect with Steadfast Services if you are interested to get work permit, travel visa, work visa etc in Dubai, Poland, Malta and Europe. We can be the right choice for you. Residency Visa in Poland

    ReplyDelete
  36. Great content and thanks for sharing with us. do you know how to start youtube channel

    ReplyDelete
  37. Nicely Described! To support the demand for node.js app development, I would also like to share that, 43% of Node JS devs use it for enterprise applications and 85% use it primarily for web app development in 2022. Constantly, node.js development companies are rising rapidly with the increasing demand of node.js development services.

    ReplyDelete
  38. If you looking for a Housing and flat so Exotica Housing will be the best quality product for you so go with exotica housing
    top 5 builders in noida extension

    ReplyDelete
  39. Do you want to build a website? Whose goal is to elevate your digital presence? Are you a business owner, entrepreneur or start-up, do you want to build a website specifically to promote your product, brand or idea? Then CSS Founder will help you, contact us for more information
    Website design company Barrel

    ReplyDelete
  40. I will tell you about a company which is trusted by millions of people. Are you searching for a good web design company, contact us?
    Website design company Lod

    ReplyDelete
  41. Thanks for sharing an informative blog keep rocking bring more details. Blue Prism Training in Chennai | Blue Prism Course in Chennai

    ReplyDelete
  42. Because of the rapidly increasing web development and web designing, it is important for any company to have a website of its own. We should have our own website so that we can reach good information about our company CSS Founder is the best website design company, contact us to connect with CSS Founder
    Web design company Thunder burg

    ReplyDelete
  43. Thanks for providing the best and nice information about it. This is very good. I hope, i will read your next blog soon.
    Medical center in Dublin

    ReplyDelete
  44. If you are looking for an SEO company in Bahrain so you could connect with Promotedial, It can provide you high ranking on googel search engine. For more information please visit our website.

    ReplyDelete
  45. We are providing the best smartphone insurance services against accident, damages, water damages, and stolen of theft. You can connect with us for more information.

    ReplyDelete
  46. I got something valuable information from your blog. Thanks for posting it
    iPhone 12 pro max insurance

    ReplyDelete
  47. Get a high ranking with CSS founder, It is the best Web design company Seattle, If you are looking for a website design company so connect with us. 

    ReplyDelete
  48. This comment has been removed by the author.

    ReplyDelete
  49. I truly love how it is easy on my eyes and the data are well written. I am wondering. Patient Care Services in Varanasi

    ReplyDelete

  50. Thanks for sharing this Informative Blog.
    https://www.fastprepacademy.com/gmat-coaching-in-hyderabad/

    ReplyDelete
  51. This comment has been removed by the author.

    ReplyDelete
  52. Robot Framework is an open-source framework for automated testing used in acceptance testing and test-driven development. The writing of test cases adheres to many test case report approaches, including keyword-driven, behaviour-driven, and data-driven.To know more about robot frameworks join Robot Framework Test Automation Training In Chennai at FITA Academy.
    Robot Framework Test Automation Training In Chennai

    ReplyDelete
  53. thanks for sharing wonderful information about Edge SPDY, Node.js, and Express.js , keep posting interesting subjects. Salesforce Course In Pune

    ReplyDelete
  54. Thank you for sharing such an insightful blog post! "Get expert Business Assignment Help for guaranteed success. Our professional team provides comprehensive assistance and delivers high-quality solutions tailored to your specific needs. Achieve exceptional grades and excel in your business studies with our reliable and timely assignment support. Contact us now!"

    ReplyDelete
  55. Excellent weblog, many thanks a lot for your awesome posts! leer mas
    our web site sclinbio,com

    ReplyDelete
  56. Excellent weblog, many thanks a lot for your awesome posts! leer mas
    our web site https:/sclinbio,com/

    ReplyDelete
  57. I realy appreciate you sharing this great article post! I read and learned a lot "Get refuse compactor 14 cum online to guarantee success." Our professional team offers a wide range of machines and high quality compactors to suit your specific requirements. Get exceptional demo in your refuse compactor machine with our reliable and timely engineers. contact us now!

    ReplyDelete
  58. Nice Post. Ethical Hacking Training in Pune, Ethical Hacking Courses in Pune and Ethical Hacking Classes in Pune.

    ReplyDelete
  59. This blog post discusses the challenges and successes encountered while attempting to integrate edge versions of node-spdy and express.js. Despite initial concerns about compatibility, the process was relatively smooth, highlighting the promising future of SPDY on node.js. Embedded Systems Course in Hyderabad

    ReplyDelete