App Center Analytics correlation id for server requests - visual-studio-app-center

I have a React Native application with MS App Center SDK installed, and would like correlate the client side Analytics events with the backend http server running on node. The SDK exposes a startSession() method, but doesn't expose a sessionid property which could be used as a correlationid sent to the server.
Is there a simple way to correlate Mobile App events with that on the server side ?

Related

Socket.IO service with API Gateway technic

I'm using microservices technic with node js and express, i used API Gateway(node js service that support https) that transfer the api requests to the other services, also i'm using SocketIO as a node js service.
I would like to know what will be the best way to securely connect to the socket IO service from the client if i used API Gateway technic.
There is two approach that i'm considered:
Use the socketIO service as a independent service without go through from API Gateway.
some way to transfer from API Gateway to socketIO service
Any advise from someone that solved this case?

Push Notifications RESTful WebApp Angular2 / NodeJS

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

Proactive Conversations

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.

Node.js Server Sent Events with Load Balancer

I am working on a node.js based Web application that needs to be able to push data down to the browser. The Web app will be sitting behind a load balancer.
Assuming the Web app has a POST REST API as:
/update_client
and assuming there is a third-party application calls this API to push some data to the Web app, and then the Web app pushes the data down to the browser.
Now assuming I have two servers behind the load balancer, with the Web app running. A browser client connects to server 1 to listen on the event. Then the other applications hits the /update_client API at the server 2. Now since the two activities happen on two different servers, how can server 2 notify server 1 to send the data to the connected clients?
And what if I am using auto scaling, with dynamic number of servers behind the load balancer?
You need to have some kind of shared resource behind the servers so they all know about updates. I show how to use Redis Pub / Sub for this in a blog post I wrote recently.
Server Sent Events with Node JS

Connectivity between NodeJS applications behind load balancer

I'm currently working on nodejs application and I got small issue.
My NodeJS application consists of 2 parts:
Internal API from other applications. Let's call this part API.
User faced web server (Express + Socket.io). Let's call this Web.
We're receiving a lot of calls to API from our other internal applications. Some of this calls would generate notifications to web users (let's imaging it's online-chat).
So if we have message for client #1000 and he's online (connected to Web application through Socket.io) we would emit message throught Socket.io to this client. Everything works fine.
But there is an issue.
We're going to introduce load balancer between our NodeJS application (it's one application, so both parts - API and Web would be behind the load balancer). Now let's imagine that we have load balancer and 2 servers with this application: server1 and server2.
Thus some of API calls are sent to server1 and some of them are sent to server2. So let's imagine we got API call to server1 and this call should send a message to client #1000. But this client has open connection to server2.
The question is: is there any best practices or common solutions - how these two servers should communicate? One of possible solutions could be open socket connection between all servers with nodejs application and if we need to send a message to client - just broadcast it so every server could check if client is connected at this moment and send the message to correct client.

Resources