Using nats with angular to discuss with Hemerajs microservices server - node.js

I need a piece of advice.
Indeed I am writing an Hemerajs (Hemerajs) server application couple with a NATS (NATS) messaging server.
Moreover I'd like to plug an Angular 6+ front application on this server through the NATS pub/sub system.
However I did not find any package or help for using nats with angular.
May I misunderstood pattern messaging behavior, perhaps the messaging system is only internally of microservices server and the communication between angular and node must be with REST API ?
Could you help me for finding the correct package or the correct way to implement this please ?
Thanks
Regards

At the time of writing there is no official Angular client and ts-nats was written for node.js aka server side.
There are
https://github.com/isobit/websocket-nats
and
https://github.com/isobit/ws-tcp-relay
But they had no updates for 3 years. I'm not sure if websocket-nats was written for nats v1 or v2.
The client protocol is documented here: https://docs.nats.io/nats-protocol/nats-protocol and the following page talks about implementing your own client.
So far nats seems to be for service to service communication only, since there are no official clients for browsers.

Related

Does zeromq provide TCP security while communicating to nodejs apps?

I have integrated zeromq in 5 applications those are running on nodejs and nginx proxy. I want to know the best way to secure the tcp communication between 0mq and nodejs app - I am mostly using PUB SUB method.
Currently for security I am using req rep method to share a key with queue id before any connection. this key I am using into SUB.
What are the best standard for zeromq tcp security?
ZAP CURVE for nodejs zmq lib.
There are few libraries those are in beta but I have implemented Curve Machenism it is working fine no breaking issues
you can use REQ REP also with ZAP module. But best I felt CURVE machenisim.
https://github.com/msealand/zmq-zap.node/tree/master/examples
http://rfc.zeromq.org/spec:26/CURVEZMQ
https://en.wikipedia.org/wiki/Elliptic_curve_cryptography
Just go through documentation and if you face any problem while implementing it please post separate question.

Add Meteor to exist node app

I have a node app that uses mongodb and mostly angular1 on the client.
The node app expose REST API, WebSocket, TCP socket and handle business logic and login logic.
I'll like to understand what it takes to either add Meteor to this all or migrate the app to Meteor?
Please go to meteor.com and do a tutorial. It will help you to understand the differences better.
It is rather wide question, but by your description it feels that direct migration would be rather painful, but I might be wrong. Certainly rest api, websockets, tcp sockets and login logic would need to be rewritten. And most likely business logic as well, to use Meteor reactivity. Without that, it would be no gain from such migration.

What is the best framework and difference of nodejs framework

These days I try to develop real time application using nodejs.
That application want to update the dashboard according to api data.
I installed express and faye and try to compare what is the best and what are the differences of that two.
As I know express is a node base framework and faye is a subscriber/publisher based one.
But I think both are almost same and anyone can help me to identify the differences?
What is fast and what can be done using the frameworks like that ?
Thanks in advance.
They are not very comparable. If you want to create a real-time application, you will probably need to use both.
Express is a web framework. You will need it to serve and handle HTTP requests and responses. It will help you handle things like url routing, request/response handling middleware, interfacing with template engines, etc... Express is as fast as you'll get.
Faye is a pub sub messaging system- It will not be capable of handling standard HTTP requests and responses. You may be able to implement a live stream of the data using Faye, however, you will still have the need to serve up your client side application using Express.
I would also look into Socket.io as an alternative to Faye- in addition to Express.

Node.js with socket.io

I am looking to build an web application using node.js and possibly socket.io but I am having a lots of confusion regarding whether to use socket.io or go with plain http. In the app the node.js server will be basically an api server which serves json to the javascript client or may be mobile clients too. The web app will also has chat messeneger for its users, this is where socket.io comes in.
I am not sure whether to use socket.io for the whole app or only for the chat part. Although my app itself could benefit from socket.io but its nothing that I think can't be done using plain http and client making more requests to the server.
I have read at several places that sometimes socket.io can be difficult to scale for more users.
Socket.io often crashes and specially creates probs when there are firewall in clients system.
More importantly.....I checked out socket.io user list and did not find many users, so was curious to know what kind of platform is more know chat network like facebook messenger, google talk etc are built upon, Are any built using http-ajax and continues querying to the server.
Please help me out in solving this question. Some might argue that this is a opinion based question. But what actually I am trying to figure out the implementation of socket.io and its limitation.
I would suggest serving your API over HTTP and leave the real-time business to Socket.io. If you are adverse to using Websockets, like #GeoPheonix stated, you can choose from a variety of transport methods using both socket.io and sockjs (https://github.com/sockjs/sockjs-node).
As far as scaling is concerned, I deployed a socket.io based real-time analytics/tracking service for a very large application with ana average of 400+ concurrent connections with no visible performance impact, but this may depend on the implementation and hardware.
Socket.io is faster than plain http. I recommend you to use it for all since you have to have a chat in first place.
In my case, real-time Texas Hold'em-like game can receive up to 2500 concurrent with one node process. However, if you change transport from websocket to xhr-polling, It can receive like more 10x than pure websocket. Your application is just chat so, I guess a little slow down wouldn't be a problem. If you sure you will exceed this number, yes, scale socket.io is a pain.
This problem will happen only if you open socket.io for port other than 80 and 443. If you have frontend web server with other language already, you can still use socket.io on another subdomain to be able to run on port 80 without conflict with your main frontend web server. Socket.io support cross-domain without a problem.
Have you used trello.com? If not, try it :). It's best for task management or even some Agile thing. They used socket.io. https://c9.io/ is another one. It's online IDE with google doc-like collaborative. One thing to note is xhr-polling trasport in socket.io is the same with http-ajax with long-polling (Better than general ajax). You can read more info at:
http://book.mixu.net/node/ch13.html

Connect node.js and signalr via sockets

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

Resources