node.js, XMPP Strophe.js - node.js

I am currently thinking of adding a realtime notification system to my site and so far my choices are using node.js or an XMPP server with a js XMPP librairy such as strophe.js.
Right now i will just need it for a realtime notification systems on my site, but it will likely evole in more complexe features such as a chat system.
So i have the following questions:
How do these 2 technologies differs ?
Which of these 2 technologies would be "more suitable" to integrate in a site running on a LAMP environement.
Thanks,

If you want to use xmpp then you have 3 choices for the server technology to use:
Jabber2 (C++)
eJabberd (Erlang)
Openfire (Java)
Prosody IM (Lua)
so if you want to develop some unique server-side functionality you should have some skills in C++, erlang, java or lua. I use openfire because I'm familiar with java. Openfire also provide good plugin system. But if you just want to have some chat on your website then you can just setup one of these XMPP servers on your server-computer and the only thing you need after that is to code some browser-side functionality using strophe.js (which is pretty simple).
If you don't want to go with c++, ejabberd, java, lua and you still need some server-side functionality use node.js.
Both xmpp and node.js chat applications can be integrated with LAMP websites pretty easily (you only need to modify your website javascript, no php code needed), but if you prefer LAMP technology I bet node.js is the right thing for you.

XMPP is a protocol. The most common server implementations are ejabberd (Erlang) & Openfire (Java). Web clients connect over BOSH (long polling).
Node.js is simply an environment for javascript execution. Something like socket.io, is really more of a transport abstraction layer. It's up to you to design & implement your communication protocol.

Related

What is absolutely necessary to have a website running on the web?

After a couple hours of searching top lists of free "web servers" and "web frameworks" on google, I realized I'm not sure what I'm looking at.
Let's take a couple of example softwares I have come across :
IIS
Apache HTTP server
Apache Tomcat
Socket.io
Node.js
Django
Questions :
Do all these work on the same scope/do the same thing?
If not, what is absolutely necessary to have my "helloworld.html" acessible from anywhere with internet? Let's consider I already have a dedicated server and a domain
Also if not, how do these work together/compliment eachother?
Each of this software has a different description on their website for what it does, what it is, who should use it, it really gets confusing when you're trying to find what is "fresh", what the cool kids are using
IIS and Apache are web servers that support a variety of different technologies for plugging code into the web servers. So, if you were using one of these web servers, you would also use some other framework and language runtime to plug into them.
Apache Tomcat is a Java-based server framework for web applications. From the wikipedia page: "Apache Tomcat, often referred to as Tomcat, is an open-source Java Servlet Container developed by the Apache Software Foundation (ASF). Tomcat implements several Java EE specifications including Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket, and provides a "pure Java" HTTP web server environment in which Java code can run." It may be used independently of the Apache Web Server. The "Apache" in the name has to do with it being part of the Apache open-source organization. So, if you want to program your server in Java, this is one of your options.
node.js is a Javascript-based framework that is both a framework and it's own web server. So, if you want to program your web server in Javascript, this is your main option. There are additional frameworks you might use with node.js such as Express to make programming your web server simpler.
Django is a python-based framework. If you want to program your web server in Python, this is one of your choices.
socket.io is really not like any of the others. socket.io is a layer on top of webSockets that gives you a whole bunch of additional features over webSockets. This would run in whatever server-side language and framework you were already using and you would have to select a socket.io library that was compatible with your server technology. You can see a list of features that socket.io adds on top of a webSocket here: Moving from socket.io to raw websockets?. webSockets themselves are used for continuous communication between server and client (more efficient than repeated Ajax calls) and for push notification from server to client.
So, if you were looking to select a technology from scratch, there are a number of different ways you could start your selection process.
If you have a preferred language (Java, Python, Javascript, Ruby, C#, etc...) you either know already or want to learn, then you can look at the frameworks that support your language and start there. The framework will indicate whether you need a companion web server or whether than is already part of the framework.
If you have an existing hosting company that you want to use, you may need to understand which technologies they support so you don't select something that would require you to change hosting companies. Not all hosting companies support all technologies and some are better specialists in some technologies.
If you have specific 3rd party code or libraries you want to use, you may want to investigate which languages/frameworks it can more easily be used with.
What is fresh and what the cool kids are using changes pretty regularly. I would suggest that's a crummy criteria. What makes more sense is to understand which technologies and frameworks are doing well with accelerating growth and a rich development community behind them vs. which ones may be falling out of favor. I haven't myself done any sort of overall survey to offer any sort of list of what's on the upswing and doing well vs. what is more stagnant.
I'm personally partial to node.js and the huge NPM library of open-source and compatible code you can draw from and the ability to use one language for both front-end and back-end. It is certainly one of the choices that is growing rapidly and has a vibrant development community behind it. But, it is not the only choice that would meet those qualifications.

The most efficient notification system for a web application

I have VPS hosting for a business application. It has XMPP based chat with Openfire which is working fine.
I want a real time notification system as well in our system.
I have these options
Ajax Long Poll
PHP websockets
Node.js
Using XMPP(Not sure if applicable)
Among all the above. Which one would be the quickest one?
XMPP over websocket would be a good fit as it simply builds on your existing infrastructure.

Methods for calling APIs in one Nodejs app from another Nodejs app

Our application will have a website and a mobile app both communicating to the same API backend. I have one Nodejs application for serving only APIs and a second Nodejs app serving html pages for the website. I am using Expressjs web framework for both of these apps.
What are different methods to call APIs in one Nodejs from another Nodejs app? Additional information on when to use each method would be great.
EDIT:
Example,
I have the following applications
NodejsAPI (node & express)
NodejsWebsite (node & express)
MobileApp
NodejsAPI will provide access to APIs for the MobileApp and the NodejsWebsite. MobileApp will access APIs over http. But I want to know what are the options for NodejsWebsite to call APIs in NodejsAPI app. From what I understand this will be inter process communication between the two processes. For .net applications such communications could be done using .net pipes, tcp communication etc. What are the equivalent methods for Nodejs applications on unix and linux platforms?
Thinking from IPC perspective I found the following to be useful,
What's the most efficient node.js inter-process communication library/method?
https://www.npmjs.org/package/node-ipc
There's node's vanilla http client, http client swiss army knife, request, then there's superagent, similar to jQuery.ajax. To make your life easier there's armrest and fementa, both different flavors of the same thing.
Now if you want to reach for more performance and have another interface of your application, you can use one of these RPC solutions:
dnode: One of the most popular solutions. It's makes things very easy. It's makes using remote interfaces seamless. phantomjs-node uses dnode. Doesn't perform well with huge objects compared to others. For small stuff, it's perfect. There's other ports for other languages too.
zerorpc: Uses zeromq as it's socket library which is famous for being reliable. It supports connecting to a python client too.
smith: RPC systems used in cloud9 editor backend. Basically almost as nice as dnode, but faster. Both smith and zerorpc uses msgpack instead of JSON, so they will save bytes on the wire.
axon-rpc: A lightweight solution. As nice to use as zerorpc. You can configure it to use msgpack with axon-msgpack.
All of above work on both TCP(To be used on different machines) or Unix Domain Sockets(faster than TCP, but only on the same machine).
If you want more performance, you can embed your NodejsAPI in your NodejsWebsite, by just simply requiring it's interface module.
If you want answers better than this, write a more specific question. The question as it is, is too broad.

Qt Application - node.js server communication

I want to make a desktop application (since its supposed to be cross-platform, I've decided to stick with Qt, and I am already familiar with it) which connects to a server. The app is similar in concept to a chat application. I know that there are application servers, however as of now, I'm familiar with web server frameworks such as rails, and am trying out node.js currently.
I wanted to know how should I ask my application(Qt-based) to connect to the server, and the main question is, how should I implement the server? After thinking up of various options, including porting the whole project over to as a web-app, I've decided that the best bet would be to use the app to somehow connect to the node.js server and it will serve the html files which will contain the command for the app. Am I on the right path?
Can this (Qt-app & node.js server communication) be achieved in the way I am thinking? Is it the correct method?
It is easy to communicate with node.js app by socket. Using node.js to create a Net server (http://nodejs.org/api/net.html), and client use socket to connect to it. In my opinion it is easier to build a server with Node.js than C/C++ and has nice performance.
BTW, I think using node.js as server has gradually become a common solution. And My company have developed a mobile game with pomelo which is a node.js game framework.
For more infomation you can see this article http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js

Mobile App chat server development

I have been tasked to develop a mobile chat app that will run both on Android and iPhone devices. I will be developing the respective clients in their native languages. Where I am a bit confused is in the development of the server.
My intended approach is to use 'long polling' to retrieve messages from the server and a separate connection to send messages to the server using GET/POST (obviously, there is no need for this to be long polled). My initial intention was to use Apache & PHP?MySQL for the server, but after a bit of reading, I learnt Apache won't be able to survive when there are lots of concurrent connections. I also learnt Node.js can survive where Apache failed by its capabilities to handle a lot of concurrent connections. Though, I don't have any knowledge about Node.js but if it will work, I am willing to do a crash course on it.
I know 'long polling' isn't the best method, but I can't seem to understand how XMPP can work for me on this project.
Thanks a lot in advance.
XMPP is the best way. You can install openfire on server side and for android you can use asmack. For Ios you can use xmpp lib.These are best combination. Communication with server is done through ssl connection.

Resources