Need to use Apache Kafka in my React-Native app - javascript

I've used Apache Kafka in my project and need it integrated inside a react-native app which is also part of the project. Basically, my server is a Kafka producer and the app needs to listen to topics and be a consumer.
At first, I tried using this npm package. https://github.com/SOHU-Co/kafka-node.
But this package relies on core modules of nodejs that are not part of the React Native bundle. Is there any other way so as I could communicate using Kafka inside a React Native app?
Thanks!

A quick solution would be to put the Kafka cluster behind a simple REST API. Using a library like kafka-rest could be an easy way to connect your React Native app using the built in fetch function. You could go a step further and try to integrate the kafka-rest-node client into your React Native app; a cursory overview of the repo doesn't lead to any core Node dependencies.
Another method, one which would allow for "live" updates, might consist of putting Kafka behind a web server that converts the Kafka stream into a WebSocket connection. Libraries such as kafka-websocket allow clients to both consume and produce, whereas a more simple library like Microsoft's kafka-proxy-ws only allows for consuming messages.
It's worth noting that mobile clients don't always work well with streaming data, and you'd be advised to test your WebSocket-based implementation on a variety of uncertain network conditions (latency, dropped signals, etc).

Try DeepstreamIO.
It's a real-time socket server that integrates well with both React-Native and Kafka. It can use Kafka as a message broker to communicate messages between distributed Deepstream nodes and push messages to other subscribed clients. They are open source so you can configure their connectors to your specific needs.

Related

Why in socket io they having set of script lines in html page?

I am trying to develop a flutter chat app using nodejs and socketio.i'm just getting started with the socketio i have surf several examples in which every front end or client side having a set of socketio script. Can i develop my code purely server side? so that i can integrate with any type of front end.
You can do that. Socket.io is a web socket implementation in node js. It enables real-time, bidirectional and event-based communication between client and server.
Server and client can send and receive the events. If you don't want write any script in client side then you don't have any use of sockets.
Edit:
socket.io given nice example for chat application with explanation. https://socket.io/get-started/chat/
Socket.io has two distinct parts - the server and the client. The docs make this clear. There is nothing preventing you from just writing the server part, and leaving the client implementation out of the equation, for someone else to implement.
Although the main point of Socket.io is to implement the WebSocket protocol, it does so by wrapping it in its own interface, so to speak. So a socket.io server can only talk to socket.io clients, not clients that implement WebSocket in other ways. That being said, there are socket.io client libraries for pretty much every major language out there:
Javascript (main client)
Java
C++
Dart/Flutter
You also asked about React and Angular, but both of those are web front-ends, so there should be no reason why they can't use the standard Javascript client library with those frameworks.

How to Implement real-time chatting using node.js and Socket.io in react-native?

I am looking for resources to guide me across server-side (Mostly) and client-side. I have referred this resource Simple Real Time chat app. But I am not getting significant results.
I locally hosted this server-side script index.js with port number 3000. I ran this script using node index.js.Parallelly, I ran the react-native code (Android Platform) and made sure that socket.io listens the port number 3000. But when i do any sought of communication from the server side or client side, i am not getting any results.
Let me know if these links are will help as resources:
Simple Chat App
The GitHub to the above mentioned Chat App
React Native Chat App
Node.JS Websocket Chat App
Android, NodeJs, and Socket.io ChatApp
I read the code and I can't say what exactly is the problem but I will give some advice
in server code user createServer method instead of server in
var server = http.Server(app);
in client code try to defer(stall) the use of any method on the socket for the next tick in the event loop using a fake non-sense setTimeout like
....new Socket
....setTimeout(() => { ...socket.emit }, 0)
because this will garantes the socket is well connected and you didn't use the emit on non-ready socket
I've tried using socket.IO once in react-native it works great back then.I wonder what could possible go wrong in your case!
try at least with a smaller example app then find out if there is any problem with this one.
and a piece of advice..check Rocket.chat and if you find it suitable I can help you with building the client cheerfully
Please consider use Firebase for this. Check these links:
How To Build A Chat App With React Native
Build a chat app with Firebase and Redux tutorial
This one is a complete functional app

how can i access mail from a microsoft exchange server using javascript?

I am trying to build a desktop app using electron that retrieves mail from a specific mailbox (microsoft exchange server), now, i have looked around and read that mailbox connection should be done server side (the question was made by a guy building a web based app that is a little bit similar to what i want to do), but, since i am not really deploying a node js server but rather using electron, which, as far as i understand is like a desktop app version of node, im not sure on which approach to take. Should i use an api? does microsoft has any interface for this? or should i use a third party integration for it?
It looks like the Exchange Web Services API is only provided as a CLR assembly, so if you wanted to use it you'd need to:
write a C# console app that you then spawn from your Electron app
(and communicate via stdin/stdout), or
use the EWS API in your Electron app via Edge.js
Alternatively, you could probably just directly communicate with the exchange server using SOAP messages, but that could be a bit tedious to implement.

How to create an application Independent notification server?

i have created an notification server, which is application specific, now am preparing an application independent server to send notification to the clients using that application for synchronizing purpose, am not asking code and all, will you give me suggestion on this.
What is the basic need for an development of application independent component?
The best thing to do is to create a message queue (pub-sub) that different applications can connect to easily.
If your app isn't that big you can create a TCP server and send information to everybody connected. If you need to scale your app you can use something like Redis, ZeroMQ, RabbitMQ etc.
You can checkout my Twitter Steam application to see how I achieve that:
app: https://github.com/alessioalex/Presentations/tree/master/WebUp4/applications
TCP Server implementation: https://github.com/alessioalex/Presentations/blob/master/WebUp4/applications/twitter-streaming/tweetBroadcaster.coffee

Using Gigya API with node.js

For one of my projects I'd like to try out Gigya as my social network connection provider and am writing my app using Node.js. Has anyone done this?
Gigya provides a JavaScript API that is intended to be used on the client.
http://developers.gigya.com/020_Client_API
It should be possible to adapt that for server side use.
Gigya's client side javascript is intended to be run in the browser as much as possible, since they perform 2 part authentication using cookies set by their domains. You can try to port it to run server side, but none of the public methods will work as advertised.
I've written a wrapper for their REST API using their proprietary authentication that I've been using in a work project for a few weeks: https://github.com/jproulx/Gigya-Node-SDK -- note that not everything has been tested thoroughly as I've only needed to use a subset of the socialize services on the server side. It should serve as a good jumping off point to bootstrap something for your needs.
Gigya does not yet have an official Node SDK. However, I've written an SDK that implements the entire service.
In addition to the standard APIs, it contains special support for streaming data from Accounts & DS.
Git: https://github.com/scotthovestadt/node-gigya
Install with "npm install gigya".

Categories