Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Subscribe/Publish messages to/from SocketIO/nodejs server from Java application?

Subscribe/Publish messages to/from SocketIO/nodejs server from Java application?

Problem

Having a NodeJS + SocketIO Server in javascript. Are there options to have a Java application to connect to that NodeJS/SocketIO server so that it can publish and subscribe messages?

Problem courtesy of: Rolando

Solution

I made something similar recently for teaching (node.js server, java client in publish/subscribe).

Actually, you should consider Faye : http://faye.jcoglan.com/ You can attach a websocket and/or bayeux server in a node.js instance using faye.

You can then connect any client that implement one or both of these protocol.

I successfully used it in the past for a lab with students in which a server is node.js publishing information, and a java client subscribe to faye using the cometd library (http://cometd.org/).

Source code of :

  • this server with faye but also traditional http server is located at : https://github.com/cgravier/WI-UCLab/blob/master/context-server-nodejs/simulateArduino.js
  • the java client using Cometd : https://github.com/cgravier/WI-UCLab/tree/master/context-client-java (sorry it is a library hell, it is designed for student that I was explicitly told were not familiar with maven (or equivalent), and it is 3h lab... anyway.)

Although the document is in French, I guess the figure at page 4 in https://github.com/cgravier/WI-UCLab/blob/master/lab%20document/context-awareness.pdf is self explanable.

HTH

fafhrd

Solution courtesy of: Fafhrd

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Subscribe/Publish messages to/from SocketIO/nodejs server from Java application?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×