I'm working on a Restful Web Application. I divide frontend and backend, using Angular2 for the front, and NodeJS for the back.
I would like to use Notifications and push them to specific users.
Sample : If my user decide to subscribe, he could get a Desktop notification when I decide to send one or if my NodeJS serveur want to send a message to a user group.
I have seen a lot of differents modules for the frontend and backend, but I'm a little bit lost.
Architecturally, how should I add this service in my application?
Should I use specific node modules?
You talk about desktop notifications. I guess you want the user to receive its notifications also when the browser or app is closed. In that case you need a Service Worker. A Service Worker is a script that your browser runs in the background, to which the message is being pushed when the browser or app is closed. For a nice introduction to Service Workers, read this. Angular has a Service Workers implemented in production version since 5.0.0. Klik here to read more about it.
At the backend you need a special Node module to send the notification. For instance node-pushserver, but there are many others. This special node module connects to a messaging service whom actual send the message. You can use for instance Google's cross-platform messaging solution Firebase Cloud Messaging (FCM) (the successor of Google Cloud Messaging (GCM)). It can send to Web, iOS and Android.
At the client side you need to register the Service Worker for push notification. Then you will get an endpoint that needs to be stored at the node server side. You send a push request with this endpoint to the messaging service every time.
You can also make use of a paid push notification provider to do the job. Click here for a list of them.
Setting up a WebSocket connection (like socket.io) won't work since it can't stay connected with the Service Worker.
You can use WebSockets for pushing data from the Node.js server. Add the ws package to your server's package.json. Take a look at the BidServer.ts here: https://github.com/Farata/angular2typescript/tree/master/chapter8/http_websocket_samples/server/bids
The Angular client is here: https://github.com/Farata/angular2typescript/tree/master/chapter8/http_websocket_samples/client/app/bids
Related
Let's say, I have an enterprise application runs on Azure Web App Service. Among 100+ pages, I have 3-5 pages needs to be served real-time. to benefit from real-time capabilities of Azure SignalR Service, I want to make clients land on my SignalR application (which runs on RignalR Service). But I couldn't find any related example-article about it. How can I invoke a Hub method outside of the code? Any other approach to solve my problem is more than welcome. My main concern here is the performance of real-time pages.
If you have an ASP.NET Core SignalR Server (i.e. you have classes deriving from Hub in your application), you can't directly send messages to clients via the Azure SignalR Service. You'd have to provide an API in your ASP.NET Core application that does that.
Azure SignalR does also support a "serverless" mode in which you don't have a Hub on the server at all. In that model, clients connect directly to the service (instead of first connecting to your app) and then you can send messages to those clients using the REST API. This is a relatively new scenario so there isn't a lot of documentation. There are some blog posts and videos online on the subject, but not a lot of documentation.
If you already have an ASP.NET Core app, I'd suggest doing this by adding a REST API to your own application that allows other services in your application to send messages by calling this API. In the implementation of this API, you can use IHubContext<T> to send the messages.
I'm reading the very limited information about Azure SignalR service as well as the quick start guide and want to make sure I'm understanding this correctly.
We still seem to have a hub and if I understand this correctly, the function of Azure SignalR service is to simply push the messages to connected clients.
In my case, I store the history of chat so by hitting the hub first, I'm able to still use my backend logic to persist chat history or do any other processing that I may want. Then simply allow Azure SignalR service to push the data to connected clients.
The main benefit seems to be handling the scaling of the service.
Am I getting this right?
Yes, you are totally right.
You will use exactly the same API of ASP.NET Core SignalR to write your business logics, which means you can persist whatever you want when the messages from clients hit your hubs.
Azure SignalR Service will be the underlying transport between your app server and connected clients. For example, when you want to broadcast messages to all your clients, you actually only send one message to Azure SignalR Service and the service will broadcast the message to all clients for you. So that you don't have to worry about the scale-out. Azure SignalR Service will handle the scaling-out for you.
You understand correctly.
SignalR is not yet ready for production (when speaking about ASP.NET Core), SignalR for ASP.NET MVC has been around for a while (stable).
SignalR consists of 2 pieces: server and client. The server is as you describe: a "hub" that you can use to push information to clients.
On a webpage you load a piece of generated javascript (generated automatically from your hub definitions). Basically you let your website visitors (clients) connect to the hub through signalR's mechanism (signalR will choose the proper way to connect depending on the browser), and then 'subscribe' to the different methods you have active in your hub.
The workings are simple: whenever you call code in your hub (can be from clients, or from backend code) communication is automatically handled for you to all subscribed clients.
Note: If you are running this on an azure web app: enable the "always on" setting, and set the "websockets" toggle to "enabled", otherwise you'll see strange behaviour.
Note2: The RC version for signalR core 1.0 has just been released (7th of may 2018) so it might be a while before this software starts becoming stable and available through the public nuget/npm channels.
Best way to get notifications to Angular Client from an Azure hosted Web API
I'm creating an app where users can interact on articles. The back-end is asp.net core 2 web api. Front end is nodejs Angular universal app. I've decided to host on azure.
I need to get user notifications from server to the client. So if an user wrote a document and another user liked it, the notification will be sent to the user that wrote it, if the user is running the site.
I know I can achieve this using SignalR or Socket.io, but I was looking for something that azure provides.
Is there anything in azure that I can use, such as Event Hub, Event Grid or NServiceBus where there's already a javascript client that works on the browser, listening on Events?
hi best way notification is azure web job with azure web hook
using web job you can get notification to any devices
for more details please see
enter link description here
https://docs.botframework.com/en-us/node/builder/chat/UniversalBot/#starting-conversations
I've been successful at using this approach in the emulator environment, where the MS bot templates use the ChatConnector and a restify server to process incoming requests.
Can it also be used when deploying on the Azure Bot Service? In that environment the bot templates generally have you using BotServiceConnector and there is no restify server.
I added one to listen on a specific port so that I could try and trigger the proactive beginDialog. I'm getting literally no response.
Since this is Node.JS Bot Framework and not a Bot Service (these are different), you should try deploying to a new Azure Web Service using the Node template. You can do a search for the Node template when creating it.
After that, the Web Service will listen on port 80 by design and respond appropriately. The local settings are for debugging locally AFAIK.
I would like to use websocket to notify a remote website whenever a table insert is triggered on my Azure mobile services.
Right now I was able to successfully send GCM notification to registered device using
push.gcm.send
in my insert script.
If i want to achieve aforementioned requirement, what are the required steps?
Setup a Node.js server, call node.js server from insert script, then node.js server use websocket to connect with remote website?
Please kindly point me to the right direction.
thanks!
One option is to use Socket.IO with Azure Mobile Services: https://azure.microsoft.com/en-us/blog/how-to-use-socket-io-with-azure-mobile-service-node-backend/
The comment posted by #gary-liu-msft is also good idea, using queues. He pointed here: https://azure.microsoft.com/en-us/blog/how-to-use-socket-io-with-azure-mobile-service-node-backend/