We are having existing Web application in Spring MVC. We are using Tomcat server. Also we have mobile app [Androis and iOs] for the same which is using spring based rest services. Now, we want to integrate chat functionality to both mobile and web application. I came across Socket.io and Node.js, which seems good. But, I am not much aware of these two frameworks. Then I came to know about Spring WebSocket.
Few Questions :
Which way is better to implement chat for existing spring based web
and mobile applications ? - Spring Websocket / Socket.io - Node.js
If we are going with Socket.io and Node.js, then how could I
configure the node.js to listen to my existing tomcat server port ?
Or I need to use separate port for client server communication for
chat functionality. [Because I tried to use same port, it was giving
Error: listen EADDRINUSE :::9090]
Any example would be the great help.
TIA.
Here is the sample application that sends messages back and forth,
Socket.io is used on client side to subscribe to a Topic of the server side.
Similarly you can use Sock.js with stomp client at client side and Spring on server side which provides an easy configuration with STOMP and also message handler annotation such as
#MessageMapping annotation which ensures that if a message is sent to destination mapping say "/hello" then the method associated with it should be called.
#SendTo annotation which is used to specify the value on which the returned message will be broadcast.
#Example stomp with spring for sending messages.
Related
I'm building a chat application with a custom web socket controller and I want to establish a two way communication between different clients with the server in the middle in such a way that whenever a client sends a request, it gets updated on the server and the server emits a response to all the clients.
Note: I've tried using IHP's Auto Refresh but using that is turning out to be quite expensive for my use case so that's why I'm trying to set up a custom web socket controller.
Check out the new IHP DataSync API: https://ihp.digitallyinduced.com/Guide/realtime-spas.html
It's higher level than websockets but likely can help you implement the chat app.
I am building an app in which I provide functionality X, Y and chat.
Lets say that X and Y are non-interactive eg. reading articles - which will work fine with REST (on a node.js server) while chat is obviously interactive so it will work best with socket.io!
Questions: 1. Is it possible for me to 'switch on' a socket between the server and the user when the user navigates to the chat part of the application? 2. Can I open up a socket inside a GET request for the url: example.com/chats/usr_id on the node.js server?
3. How can this be accomplished inside a Backbone routing framework?
Yes. Just initialize the connection when the view is rendered (via a controller or script). See socket.io client documentation. You can just connect when the view is rendered and disconnect when the view is terminated. http://socket.io/docs/client-api/
You cannot open sockets with a GET request. Socket.io has it's own build in mechanisms for connecting to a socket server. It will start with Web Socket protocol and fall back to Long Polling. You can however use custom url's for unique things. One again, consult the socket.io documentation: http://socket.io/docs/client-api/
http://www.sitepoint.com/chat-application-using-socket-io/
p.s. I'd suggest reading up on how Web Sockets work, as you don't seem to have a very strong understanding.
I'm trying to setup RabbitMQ to take web application logs to a log server.
My log server will listen to one channel and store the logs that comes in.
There are several web applications that need to send info to the log server.
With many connections (users) hitting the web server, what is the best design to publish messages to RabbitMQ without locking each other? Is it a good idea to keep opening a new connection to the MQ for each web request? Is there some sort of message queue pool?
I'm using IIS for a web server.
I assume you’re leveraging the .NET framework to build your application, given that it’s hosted in IIS. If so, you can also leverage Daishi.AMQP, which has a built-in QueuePool feature. Here is a tutorial that outlines the mechanism in full.
To answer your question, you should initially establish a connection to RabbitMQ from your application server. You can then initialise a Channel (a process that executes within the context of the underlying connection) to serve each HTTP request. It is not a good idea to establish a new connection for each request.
RabbitMQ has a build in queue feature. It is well documented, have a look at the official docs: http://www.rabbitmq.com/getstarted.html
Is there anyway to send data though sockets from Node.JS to SignalR? I have a Node.JS app that sends realtime information as JSON format. The other app it's an MVC C# app that uses SignalR to send the data to the client via socket. I want tosen data from de nodejs to signalr and signal send that info to the client.
You might consider better solution for internal communication between processes. SignalR is meant to be used between .Net server and client using different authentication, handshake, protocol and network layer methods, which is inefficient for internal server communication.
Take a look on ZeroMQ, is well simple and very easy to use tool, meant especially for such cases. It has bindings for most languages including .Net and node.js.
There is js client for browser to communicate with Signal R server.
http://www.nuget.org/packages/SignalR.Js
You probably can extract js file from it and run from Node.js.
And probably standard Socket.IO will just work, you need to subscribe to proper events and go.
If you want a node.js client for signalR that doesn't require jQuery I started this one. It intentionally only supports websockets.
https://npmjs.org/package/signalr-client
I have the following problem.
I have a chat developed with ActionScript3 (AS3), SharedObjects (SO) and RED5. Well, this works correctly. Now, I'm developing a chat using Node.js, and this works correctly too.
My question/problem is how can I connect these 2 chats. Is it possible to send messages between Node.js and RED5? I want that one user that is chatting using Node.js chat and another user that is chatting using RED5 chat, can chat together.
Someone knows some solution? It's possible?
You need to code some server side servlet in Java to proxy your Node.js messages to and from the red5 chat.
Are you familiar with the Red5 API and have some understanding of the Java Servlet Container ? Cause you will need that to implement a solution.
Red5 is a server side technology that runs in the Tomcat Servlet Container. Propably Node.js could send a message to red5 via a simple servlet, that will then forward the message to all connected clients.
The other way round you could catch all chat messages on Red5 server side and then forward the messages to Node.js (however I don't know what incoming message receiver's you can code in Node.js).
Sebastian