Utilizing Node.js Along Side Another Platform (Grails)


We have a grails application in the wild. We'd like to give users using current browsers a better experience and provide some auto-updating of pieces of the site. Looking into all the options and specifically with Grails, I'm not impressed.

I really want to use WebSockets and from the investigating I've done up to this point I believe our best option is Node.js. But obviously we can't redo our application. I like Grails.

So my idea is that we use Node.js along side Grails to basically act as a READ-ONLY proxy between the client and the data. All the Node.js application will do is pull data from the database and deliver it to the client over WebSockets.

Does that sound like a valid approach? Is this something anyone else has done?

Problem courtesy of: Gregg


Certainly sounds reasonable; I'd suggest using socket.io to implement your transport (it will use WebSockets if the browser supports them; otherwise it will transparently use various fallback mechanisms). You might want to use a reverse proxy like nginx to avoid any cross-origin problems, though socket.io is fairly good at avoiding them.

Node is very much about letting you use the right tool for the right part of the job, rather than being a Golden Hammer.

Solution courtesy of: ebohlman


We aren't using websockets, but we have an Angular app that talks to the grails via REST calls, which we expose using controllers.

Discussion courtesy of: kingd9

This recipe can be found in it's original form on Stack Over Flow.