WebSockets with ColdFusion

Today I released a ColdFusion WebSocket Gateway on RIAForge and Github. The name pretty much says it all. It is a event gateway for messaging between ColdFusion and conforming clients via the WebSocket protocol. The gateway is based on Nathan Rajlich's Java-WebSocket server implementation, which I updated to support both WebSocket draft 75 and draft 76 clients. For more info on how to install and use this gateway see the Github wiki page.

[More]

Related Blog Entries

Comments
johans's Gravatar Ben's post also triggered my interest and I played around with Pusher, since I became aware of http://beaconpush.com/ - what makes it stand out for me is that it is so simple to use. It falls back for non-socket browsers but does not require you to install a swf.
# Posted By johans | 7/29/10 5:15 AM
Jon Hartmann's Gravatar I'm very interested in trying to make use of this technology, but I am a little lost on one point... how does the server push to the client? In reviewing the documentation, I only see examples for the server responding to the client, not the other way around. If all I need is for the server to respond, a classic AJAX request is fine.
# Posted By Jon Hartmann | 10/4/10 3:18 PM
Nathan Mische's Gravatar @Jon - The server can push to the client(s) by calling the SendGatewayMessage() function. You can call this function from any ColdFusion template to push messages. Also, if an event gateway's onIncomingMessage() method returns a message, that message is automatically pushed to connected client(s).

Does that make sense?
# Posted By Nathan Mische | 10/4/10 4:02 PM
johans's Gravatar @Jon - your ajax request would have to be initiated by the web browser (client) and only that web browser would get the response.

With web sockets all of the web browsers connected to the same "channel" will receive the data sent from the server without having to make a request. Examples of the data could be a message from any one of the connected browsers (like a chat app) or a status update of a process on the server sent by the server without any request from a browser.
# Posted By johans | 10/4/10 4:12 PM
Jon Hartmann's Gravatar Thanks! I'd completely forgotten about SendGatewayMessage(), its been a while since I worked with the Gateways. In the application I'll be building next, I think that real-time server-push could be a killer feature, and I'd much rather make use of this project than try to roll my own or use a third party like Pusher. Thanks Nathan and Johan!

@Johans: Yeah, I realize the difference between WebSocket and AJAX, but I was completely forgetting about SendGatewayMessage(). When I was looking at the documentation on the site, I wasn't seeing how the server could initiate a message, only how it could respond to incoming messages. If the server can't push, than its pretty much like handling an AJAX request.
# Posted By Jon Hartmann | 10/4/10 5:04 PM
Matt's Gravatar Web sockets are the most interesting thing coming down the pike from my perspective. This is a great endeavor and look forward to using it...
# Posted By Matt | 12/7/10 7:32 AM
Kai Tischler's Gravatar Hello Nathan "The Wise ? :-)" !

When it comes to WebSockets, I automatically thought of the KEG (Kaazing Enterprise Gateway) until now; but it is NOT free for deployment ...

Please allow me to ask several questions:
- In April 2011, is Your "ColdFusion WebSocket Gateway" still recommended by You ?
- Which JavaScript/Ajax library should be used on the Web Clients ?
- I know that the KEG does NOT provide sophisticated messaging capabilities itself; of course, neither can do the "ColdFusion WebSocket Gateway"; the KEG hooks itself instead into TCP-based Messaging Engines (AMQP, JMS, etc.); how can the "ColdFusion WebSocket Gateway" be leveraged for providing sophisticated messaging capabilities from ColdFusion to Web Ajax Clients ?


TIA for Your reply

Cheers and Tschüss

Kai (Tischler) from Northrhine-Westfalia in Germany
# Posted By Kai Tischler | 4/6/11 11:36 AM
johans's Gravatar I would not bother with CF/Sockets anymore. I'd use with Node. Check out nowjs - how easy is that: http://nowjs.com/
# Posted By johans | 4/6/11 3:28 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.