Google Cloud Messaging XMPP Server with Node.js - node.js

Title is fairly self explanatory. I need to create an XMPP server in Node.js to communicate with Google Cloud Messaging. The XMPP connection should allow me to send messages from the server to the client (Android app) and also from the app back to the server without the app needing a seperate socket connection to the server (all messages routed through GCM. Could anyone perhaps guide me in the right direction?
P.S. If I have provided insufficient information please let me know :)

It seems that a simple Google search return that there is an XMPP server developed in NodeJS: https://github.com/node-xmpp/node-xmpp-server
This is likely what you want to deploy.

Related

Is socket.io or websocket safe to use with an express server?

I was wondering to have a realtime system made with express and i came to know about socket.io and websockets. But the way they are used i.e.
const io = socket.io("https://example.com") ;
Is it safe to use. Since the url for socket connection is available at client side any third party service can enjoy and exploit the services by connecting from their service. I don't have much idea about socket.io so correct me if I am wrong.
Kindly don't mark this question as duplicate since I found a similar question but the answer to it was related to game development, here I am specific about updating clients whenever any updates are there on the server side. Clients may be website made with angular or apps made with Android studio.
Any help is highly appreciable.
socket.io is widely used. It is perfectly fine for use in production.
Regarding the authentication part, A websocket connection b/w client and browser is established via http upgrade request(in http/1.1).
If you have an authentication mechanism in place for your application using cookie and session then you should be safe. No one can establish websocket connection directly without first logging in. On top of this you can limit connection per user to ensure that a registered user cant further exploit the connection using the cookie data.

Web socket connection failed after deploying in AWS

I'm working on frontend development using react. Backend is developed using node js.
In our application, we have web socket implemented in it. We are able to establish websocket connection and load server messages whenever it's used locally. (ws://localhost:portNo)
But, the problem is once after the code is deployed in aws,we're not able to establish the web socket connection.
Please suggest some ideas. It would be more helpful.
Thanks in advance!!!

How can I get an Electron and Socket.io app to run in a thin client architecture?

I created an Electron for a tiny company that connects to a Socket.io server. This app obtains the username of the logged in user and the MAC address and sends this info to the server for processing. All of this is working fine with regular desktops. Now, another company wants the same app, but they have a thin client architecture. Is there a way to get the app to run in this kind of architecture?
I am having a hart time figuring it out. I have never dealt with thin clients.
1) In the thin client architecture, would I have my socket.io server code and the app in the same server then? If they are in the same server, how could I get the app to connect to the socket.io server? They are in the same machine, so I am confused.
2) One problem is the app can't obtain the MAC of the thin client because once executed from the thin client it will end up getting the MAC of the server. Is there a way to obtain the MAC of the thin client using Node.js? Is there another way of using Node to recognize some sort of id for the thin client?
I would like the thin client to log in to the server, execute my app automatically, connect to the socket.io server, and send to it the username of the logged in user and the MAC address of the thin client. Is this possible? Do you have any suggestions on how to accomplish this?
You have to use the serverside code of the library for your server. E.g. node express.
Then you have to use the client side code of the library in a client side application. E.g. electron
Electron is a combination of node and chromium and you have to install the final build on the clients machine(s).
Of course, you can do all the things you ask about. Just read the socket.io docs. Its very easy, you can do it by specifying the host IP and listening/emitting events.

Cannot connect to socket.io on Google Cloud App Engine

Currently I am developing a mobile application with ionic 2. Within the application I got chat functionality. The chat functionality is based on Socket io in a NodeJS API. Unfortunality, it is hard to configure the socket io on Google Cloud App Engine. On my local machine it works fine.
Steps I have undertook:
use port 65080 (and open the firewall port)
2 servers (api calls via 8080 and socket io via 65080
Sample
Does anybody have a solution? Thank you in advance!
Jelle
Sadly, neither socket.io or Websockets currently work on App Engine. This is something we're actively trying to address:
https://cloud.google.com/appengine/docs/flexible/nodejs/how-requests-are-handled#not_supported
This question is almost identical to this one, and there's some new good news:
GAE support for persistent socket connections arrived in February 2019!
To make this work, you'll need to be using the flex environment and modify your app.yaml to include session_affinity.

socket.io without running a node server

I have a web application that requires PUSH notifications. I looked into node.js and socket.io and have an example that's working. The question I have is, Is it possible to use socket.io only in my client side JS without running a node.js server?
Can a third party server just send requests to a proxy server and may be socket.io just listens to a port on the proxy server and sends back events to it?
Thanks,
You need a server side technology to send data back and forth via web sockets. Socket.io is a communication layer. Which means, you need to have a server side method to send data.
However,
You can use various third party services to use web sockets and notifications. They are relatively easy to use, and they have support for many other languages.
Check some of these out:
http://pusher.com/
https://www.firebase.com/
http://www.pubnub.com/
https://www.tambur.io/
https://fanout.io/
You don't need to run Node.js to have a real time push notifications. You can use a third party service that does it for you. Most of them are cheap, sometimes free for low traffic instances.

Resources