Cannot connect to mosquitto broker from local web client on windows - javascript

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

Related

pusher without internet connection

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!

Having problems running WebSocket for mqtt

I'm trying to replicate this demo
using my own mosquitto instance to control the meter. When I try to connect to "test.mosquitto.org", 8080 everything works great, but when I plug my own mqtt server's IP I receive: Connection failed: AMQJ0007E Socket error:undefined.
I believe this is due to the requirement of a websocket service to run on the same machine as the mqtt. The original author uses WSS, and I can't figure out how to install this service (complete noob). I Even tried to follow these directions with no luck Could anyone give some directions?
You can try Installing him HiveMQ while you wait for mosquito 1.4. That is a broker with websockets built in.
The easiest answer to this is probably to wait for Mosquitto v1.4 to ship which has baked in Websocket support.
If you can't wait for it to ship you can build from the development head stream which will get you what your looking for. You've not said what platform you are running the broker on, but these instructions should help on Linux: http://goochgooch.wordpress.com/2014/08/01/building-mosquitto-1-4/
Mosquitto v1.4 has been released on February 18th, 2015. It has inbuilt support for websockets.

WebSocket Server php script

I'm building a chat system with websockets but a can't find how to keep runing the file that starts the websocket server. I'm using php, javascript and cpanel. Can anyone help me how to run the websocket server from cpanel and keep it runing like forever.
Thanks
you have to use ssh detail to connect your server from command prompt
ssh username#host-name

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

Expose socket via web sockets

I have a server that creates a socket on port 8181. I would like to access that socket from a web page opened in Google Chrome 14. I suppose it is not possible in a straight manner. Chrome provides support for Web Sockets but not for standard sockets. Is that right?
Is is possible to somehow create an intermediary that would expose my socket server listening on port 8181 as a web socket server running on some other port?
websockify is a generic WebSockets to TCP socket proxy/bridge. I created websockify originally to allow noVNC (HTML5 VNC client) to be able to connect to an unpatched VNC server. But it is generically useful (not VNC specific) so I spun it off as a separate project.
On a UNIX/Linux system you would run websockify like this:
./websockify 8080 my_server:8181
Port 8080 in the above example is the port to listen for WebSocket connections. my_server is the name/IP of your system where you have a server listening on port 8181. If you are running websockify on the same system as your server then you can just use localhost in place of 'my_server'.
The websockify project also comes with a Javascript wrapper library called websock.js. websockify supports the new protocol versions (used by Chrome 14+ and Firefox 6+) but it also works with older versions. However, with the older versions of the protocol there is no way to send raw binary data (only UTF-8), so websock.js and websockify work together to base64 encode/decode the data (between the browser and websockify) when using the older protocol so that you can still send raw binary data to/from the target.

Categories