pusher without internet connection - javascript

I'm using laravel 5.4 with pusher to build a real-time application , but I have poor internet connection so I'm wondering if I can use a pusher bridge instead and if it doesn't need an internet connection ?

You need to configure another driver for Laravel because Pusher is a third-party service (needs internet), that manages all the web socket server. I also found out this behavior of Pusher and for that, I searched for another driver. Redis is the second option. Choosing Redis requires a Websocket server to be configured in order to manage all the connection (Pusher's tasks). This is because Redis only handles the sending of messages to the channels but doesn't do everything that Pusher does.
Install Predis on your Laravel project using this command composer require predis/predis.
Install Redis on your local server.
Then install this: https://github.com/tlaverdure/laravel-echo-server in order to install a socket.io server implementation compatible with Laravel. (Socket.io will be responsible now for managing the connections into the channels defined in Laravel).

Pusher requires an Internet connection to work unfortunately - however you should know that Pusher can deal with sketchy Internet connections fairly well, so you maybe could give it a try and see how well it works!

Related

How can I connect git-hooks with an electron app

I am trying to create some mechanism which my electron app can get events from git-hooks,
how should it be done? with child process? dnode?
I am trying to find a solution that won't require me to install packages at my git repository (not the electron one)
Any suggestions?
If you're searching for OS-agnostic solution, here is what could be done:
Create a unix socket and listen it from the Electron app in some acknowledged location, like User's App folder. For example /home/user/app/bus.sock
Create a script which connects to /home/user/app/bus.sock and communicate with your Electron app. If the socket doesn't exists, then the script starts electron app and after this attempts to connect to the socket.
Run the script from git hooks.
Unix socket allows you to open network connection without listening ports (and thus without serious security flaws). And gives an ability to communicate using any transport protocol you want: HTTP, gRPC, JSON-RPC, WebSockets, etc.

How to give the server port to client

I have a node server with several node projects. I use nginx to get them all responding on port 80. Now, this works for the initial http request. For the websockets, I need to use the direct server port. To keep everything alive while developing I would like to try this, projects will have a dev and live version. Once de dev is stable, I will copy it to the live folder. The live folder is runned by a systemctl script where I define a difrent port to the live version so I can dev without taking the live down. The problem I encounter now is, how can I get the running server port in my client side Javascript so that the dev page connect to the dev port and visa versa?
currently I'm only using express, socket.io and mysql. I have no further npm packages installed. I searched allot but there is not to mush I can find. I found how to connect the socket to the page url but I cannot use that because that URL will always be on port 80. Further I found allot of huge packages that has no use for me since the original page is just static, the dynamics all run over websockets.
Is there any way to parse the port number in the clients .js file like I could do fairly easy in php? And if so, what would be the most efficient way. I could let javascript check if the page uses the live or dev URL but I would prefer not to hardcode my dev URL into JS where it is for everyone to see.
run a third node.js socket.io server program, all your clients connect to this server first.
In this simple node.js program, determine the type of clients by any means. e.g. different user id for dev/production users
send the server url and port to your client according to its type (dev or production)
you may also use this technique to separate your users to different production servers.

Creating a react-native app for IOS and I have created a Microsoft SQL server, how to connect these two?

I have an app built on react native and I want to connect to a database that i have made on the Microsoft SQL server. I have searched online and there are things like myssql but I still get errors with that. I followed this tutorial nodejs from the official Microsoft website, and it works with the nodejs and I use node to run it, but how can i use this in my react native project?
You can use AXIOS to make requests to your NodeJS Server
In Android you can access your localhost by the IP 10.0.2.2 (default proxy configured in your Android Virtual Device).
In iOS you can just use localhost
Remember to add the port assigned your NodeJS Server and the
protocol http
Example URL for Android: http://10.0.2.2:3000
You need to write back-end service code.I suggest you to use Asp.Net Web API .You can use Entity Framework.
Also you can use PHP,Java or Python...

Cannot connect to mosquitto broker from local web client on windows

I am trying to connect to mosquitto windows broker service on my machine through javascript. I understand that Paho javascript client connects only through websockets and mosquitto for windows doesn't support websockets unless you build it yourself. My question is that since I am trying to connect to localhost should it matter to have a websockets enabled mqtt broker? Is there any way to connect to a local mqtt server without using websockets through javascript? And is it unsafe to do so or is it fine since I am connecting to a local server itself?
Thanks in advance for the answer and sorry if it sounds lame to you. I am extremely new to this space.
Even when connecting to localhost you still need websockets support to use the paho JavaScript support.
There are some small apps that will set up a separate websocket listener and bridge that to pure native MQTT e.g.
http://hai-ng.blogspot.co.uk/2014/08/setting-up-mqtt-websocket-gateway-with.html

Bluetooth in Meteor?

I'm pretty new to Meteor and web development and such.
My essential question is: is there a 'right' way to communicate with a client's Bluetooth hardware in Meteor/js?
Currently, I'm thinking of writing a driver that takes the Bluetooth data and sends it in a stream to localhost, but that seems a little bit roundabout.
You would have to go via an npm module in Meteor. For this you need to make a package that uses something like bluetooth-serial-port to allow Meteor to communicate with the device using the host device's bluetooth serial port (https://npmjs.org/package/bluetooth-serial-port) (You will need the bluetooth development headers too)
Avital has made a package demonstrating how to use npm modules with meteor : https://github.com/avital/meteor-xml2js-npm-demo

Categories