Why WebSocket Apps Are In Your IBM i Future
April 13, 2016 Alex Woodie
Do you pine for the simpler days of the AS/400, when RPG was king and data was served through super-efficient 5250 interfaces? If so, you’re not alone–the relentless crush of modern technologies takes a toll on all of us. But while the world isn’t likely to go back to RPG and 5250, you might find something that works in a similar way in a new technology called WebSockets.
“It’s basically full duplex communication from client to server, but then also from the server to the client,” Bartell said. “Once a handshake has happened, where an agreed upon WebSocket is made, the server can actually notify the client of data, without the client having to poll the server. That’s one of the cool things about Nodejs is that it has very excellent WebSocket capabilities.”
IBM has adopted WebSockets technology within its HTTP Server (powered by Apache), as well as within the Integrated Web Application Server for i, the lightweight Java application runtime based on the Liberty profile of WebSphere. Developers can create WebSockets applications using either Java or Node.js.
IBM explored some of the concepts and chief benefits of WebSockets in a February 2016 paper titled Running WebSocket applications on IBM i.
“The HTTP protocol only allows a client to send a request to the server, and the server side can’t initialize a request to the client,” write the paper’s authors, IBM software engineers Tian Gant, Xu Meng, and Zheng Chang Qing. “Now, by using the new WebSocket technique, we have the ability for the server to send a request to the client.”
So, what can you do with WebSockets on IBM i? The IBM software engineers say it’s very useful for real-time Web applications, such as gaming. While gaming is great, it isn’t necessarily applicable to the average midrange shop struggling to run a business while avoiding technical complexity.
Bartell had his own examples of WebSockets in action, including one based on IBM i Dash, an open source project he created at https://bitbucket.org/litmis/ibmidash. IBM i Dash was written in Node.JS and provides a Web-based dashboard interface for the DB2 for i Services that IBM made available to basically provide SQL-based methods for IBM i administrative functions, such as the Work with Active Jobs command.
Bartell describes how WebSockets fits into the picture:
“Instead of calling a system API, I call an SQL view asking for WRKACTJOB info, and it returns back a result set,” Bartell said in the BCD webinar. “What’s intriguing is I can let the screen sit there and because it’s written in WebSockets, every two seconds it automatically refreshes for me. What’s even more interesting is, because of how WebSockets work, I only do one WRKACTJOB request for the 20 people that are on the same page, and that one request is delivered to those 20 people via an event emitter mechanism. . . There’s some very cool technology going on with very small network footprint.”
As open source technology improves, it’s giving everybody–including IBM i programmers–the power to tap into new sources of data and insight. One could even use the combination of WebSockets and Node.js to hook an IBM i application up to IBM’s Watson cloud service to automatically transcribe the audio content of customer service calls into text, and then do sentiment analysis upon the text. Bartell tried it with a free developer license to Watson, and he found it surprisingly easy to get it hooked up and running.
But within the context of WebSockets specifically, it’s fascinating how much it bears a resemblance to IBM’s 1970s era System Network Architecture (SNA) protocol, which was killed by the ubiquity of Ethernet and the TCP/IP protocol. The similarity wasn’t lost on Bartell.
“This is a significant evolution in the browser programming space because we no longer need to do the polling, which adds additional CPU cycles and bandwidth,” Bartell notes. “We’re starting to gain more efficiencies, which is kind of humorous because we’re getting back to the realities that we’ve already had with the 5250 approach. Again, IBM i had it all figured out way back in the day and the rest of the world is now catching up.”
The more technology improves, the more it stays the same.