What does this mqtt-connection module in nodejs used for? Does it means with this mqtt-connection then we do not need any broker?
mqtt-connection
You can indeed create a new server listening on MQTT and connect to it using the client version.
For exemple you can run an express app with the following architecture
-server
- server.js //Start your server here
-app
- your client views and controllers go here
However, if you are planning to setup a big application, I strongly recommend you to use brokers such as Mosquito or ActiveMQ.
Related
I have created a socket server in Node js. It is working fine while subscribing from an ejs file.
The part I'm confused is how do I keep my laravel application listening to the server I have created?
Thanks in advance.
Laravel community already come up with a solution and it's call Laravel Echo Server (Check that out) that basically just a Node + socket.io that implement all the pub/sub logic for your Laravel app.
If you want to take complexity into your own hand then you could try setting up broadcasting driver in Laravel to use Redis. In simple term, Redis is the middleman that connect your Laravel app to your socket.io app for websocket connection. This is call message broker.
For example, you have Laravel app listening and publishing event on a Redis server and Node + Socket.io server doing the same thing. When you fire an event through Laravel, your node will able to listen to that event too through Redis acting as a broker. Your node then can instruct Socket.io to do whatever it want with its front-end user.
This solution doesn't require Laravel-echo but you need to do a lot of stuff for authentication, handling private channel and presence channel .. etc.
I suggest you take a look into Laravel Echo Server as what I've describe is only scratching the surface.
I'd like to make a app with React-Native that's accept connections from another devices (Desktops or mobiles) through raw tcp sockets (like node's Net API) or WebSockets (like Socket.io). The point is that, socket server must be running on the React-Native's App.
I already tried Socket.io and react-native-tcp, it works when i make the server run on a nodeJS's application and the client on RN's app, but not the reverse.
When i try to import Socket.io and make it listen on a port, a error is raisen, because RN don't have node's http module. Just Socket.io/clients works.
I think that i'm doing something wrong, but is really possible to do that? and what is the best way?
Obs: I'm really new in RN's world.
No, we can't create a server although if we create a server we can't connect any other external applications to the server.
So create a server and deploy it in any could service then use it in your react-native app.
(I am new to Meteor and NodeJs environments)
I would like to implement a Meteor-based webapp which needs to read/write/browse files on the client's local filesystem. I used the Meteor package arboleya:electrify to make the client side webapp a desktop app, with the hope of having the access rights to read the filesystem (because if Atom can do it, then why not my app).
My problem so far is that I don't understand how I can use an API like NodeJs's fs from a Meteor client.
Edit: This question is for a client Meteor app, connected to a remote Meteor server.
Recent versions of Electrify enable an easy IPC connection between Electron's NodeJS and Meteor as RPC, allowing the Meteor client to remotely call the functions of Electron's NodeJS.
I have a node.js server, what I want is that the same server should run as a client for asterisk manager and can connect to AM using node.js.
The overall architecture will be like this :
Client interact with node.js server.
The same server acts as a client to asterisk manager.
Asterisk manager will provide data to client(which is also a node.js server)
Now the node.js server will push data to its actual client.
It's too difficult to get a nodejs compatible client, probably you will have to build a complete module which is compatible with nodejs.
My requirement was also the same, I would suggest instead of looking for any nodejs module use sipml5 client with asterisk. The audio part can be handled with sipml5 and other features can be built with nodejs.
Thanks
I'm writing similar app by nodejs.
Use asterisk-ami npm module so you can connect to your asterisk server and access required events.
Here's the link for the described module:
here's the link for the described module.
I have been breaking my head on understanding what exactly is socket.io and its role in the whole persistent communication between client and server in general. Some fundamental questions that keep coming up in my mind are :
Are node.js and socket.io server different ways of doing the same thing ? Like lighthttpd and apache ?
Why should I use socket.io server if I have node.js ?
Can I use socket.io client with another server side programming language like PHP ?
Are there alternatives to using socket.io client ?
Is socket.io client just another javascript library for websocket communication ?
Thanks :)
The Socket.IO server accepts connections from Socket.IO clients. This is not any different than any other server (such as a web server like Apache) accepting a connection from a client (such as a web browser like Internet Explorer).
Node.js is a platform built on top of the V8 JavaScript engine, which comes with a convenient library usually used for web and network applications. Socket.IO is a web-socket-like communication wrapper and RPC which enables servers and clients to communicate over a variety of transports (every thing from long-polling JSON to real Web Sockets). Generally, the Socket.IO server code runs in your JavaScript application running on top of Node.js, and the Socket.IO client runs in your JavaScript on a web browser. (Note that you can run the Socket.IO client in your Node.js application to, which I have used in the past as a quick RPC between multiple Node.js applications.)
There are Socket.IO clients available for many languages, and yes I believe there is one for PHP but I haven't used it personally.
If you want to communicate with a Socket.IO server, you must use a Socket.IO client. It is a protocol all on its own.
Are node.js and socket.io server different ways of doing the same thing ?
SocketIO is actually a I/O engine that permits realtime communication between client and server, unlike classic HTTP requests.
Why should I use socket.io server if I have node.js ?
Since both are differents, we can't compare.
Can I use socket.io client with another server side programming language like PHP ?
No, because socketIO server run in NodeJS environment.
Client first make a HTTP request, then socketIO send a static JS script to client.
This script establish the two-way communication.
But you can use socketIO server with different socketIO client implementation.
Are there alternatives to using socket.io client ?
Any socketIO client implementation can do the job since they connected to server.
But beware of asynchronous way of communication, like in Java or PHP.
Is socket.io client just another javascript library for websocket communication ?
Yes it is, but socketIO aims on reliability and easy to use, and also do best effort : It choose the best transport available for client.
Hope it helps !
Are node.js and socket.io server different ways of doing the same thing ? Like lighthttpd and apache ?
Socket.io is a framework/library for node.js
Why should I use socket.io server if I have node.js ?
It's a framework designed for two-way communication, use it if you want
Can I use socket.io client with another server side programming language like PHP ?
Technically yes. But then you would have to reimplement socket.io server in that other language to match it.
Are there alternatives to using socket.io client ?
Lots of, google for websocket/real time communication in [here put your language]
Is socket.io client just another javascript library for websocket communication ?
Socket.io client is a JavaScript library compatibile with socket.io server (which is JavaScript library as well, only on the server side, i.e. Node.js)