We are looking at using MQTT as the messaging protocol on a new device we're building. We'd also like a web interface for the device. Does anyone know if you can implement a browser client app (without additional plugins) that talks MQTT?
Yes, as mentioned in Steve-o's comment MQTT via websockets is very possible.
There are 2 options at the moment
IBM's MQ 7.5 comes with websockets support, you can find details here.
The Mosquitto broker has a javascript client with an example running here.
To answer your second question lighttpd has a websockets module that can be used to do forwarding to an existing broker with details here.
I've not been able to find anything for Apache that doesn't need you to write your own library to do the forwarding.
To extend hardillbs answer:
There is a third option now:
HiveMQ supports native websockets without the need for any external web server. It works perfectly with the Javascript client of Eclipse Paho.
If you want to try it out, the public MQTTDashboard (which uses HiveMQ under the hoods) supports websockets on port 8000.
Disclosure: I am one of the developers of HiveMQ
IBM has released a WebSockets based JavaScript client. It is open-source on Eclipse Paho.
Git repository:
http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.javascript.git/
Tutorial is here.
https://www.ibm.com/developerworks/community/blogs/c565c720-fe84-4f63-873f-607d87787327/entry/how_to_prog_javascript?lang=en
We've had good experience using WSS, the WebSocket to TCP Gateway (for MQTT). It means running a separate process, but that does avoid having to change Apache's configuration. WSS also has support for TLS.
Not Apache, but you can follow this guide to install lighttpd with mod_websocket,
http://oriolrius.cat/blog/2013/09/25/server-send-push-notifications-to-client-browser-without-polling/
but for easy of use I highly recommend HiveMQ, as #Dominik recommends.
The blog by jpmens is a good starting point to get mosquitto setup with websocket feature. He's client javascript code based on Paho is on github.
This blog "How to run your web server and MQTT WebSockets broker on the same por" explains two ways for the server side:
mosquitto with http configuration
apache+mod_websocket_mosquitto
Why not nodejs + socket.io? They come with all gadgets included (webscokets, pub/sub, webserver,mqtt broker...).
SocketCluster is another good starting point.
This link (Download codes) is useful. Download it and modify this file mosq-mqttws31.html. Instead of the embedded java script library use this cdn
https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.js
and the client instantiation should be client = new Paho.MQTT.Client("test.mosquitto.org", 8080,"myclien256tiddd_" + parseInt(Math.random() * 100, 10));
Related
I am new to using loopback, and I'm using loopback4 (which I think is referred to as loopback-next)
I have set up my controllers, models & respositories in order to be able to support CRUD operations to mysql, and that is all fine.
I want my loopback application to also connect to an MQTT server, so that I can subscribe to messages from MQTT, and react to those messages by creating entities in my repositories. In addition, I want to be able to have existing controller methods drop messages onto the MQTT (publish)
I am struggling to understand the right way to do this in the loopback eco-system.
I don't think I want to create a Server - because the documentation describes a server as including a listen port. I don't want my loopback application to be a MQTT server. I just want it to interact with one.
Similarly, I don't think this would be an MQTT bridge, or a datasource.
I suspect, what I want is a service. But I'm not certain.
I would appreciate any advice on how to achieve this integration.
Thanks
LB4 is highly extensible and a very good choice for such integrations. What you need in this case is to have a MQTT connector component. You can refer to the documentation for how to create a component in LB4 here and here.
You can refer to an example component implementation for authorization as well for quicker understanding.
I want to create a feature on my web portal where a user can click a link to open a telnet session in the browser itself. I researched the Net::Telnet library for Ruby. It has information on how to set up the connection.
But what about the web UI?
How to leverage the Net::Telnet library on the rails web app.
I have Rails 4.2.0 with Apache Passenger running on a CentOS 6.6 machine.
Because telnet is a streaming/serial type protocol and users will expect that type of experience, you might want to look into websockets or streaming http. The only other option would be to do polling to keep your view updated which seems like a very bad fit for a telnet client. Definitely an interesting problem. It appears that Net::Telnet behaves like a tcp socket connection so if you can wire that up to an http stream, which seems possible, you should be able to push it to a browser UI. Sounds like a cool project. Let me know how it takes shape.
I am working with between Linux-based machine and android app.
First of all, I need to open a server socket on the machine to communicate with the app.
I need to code with LUA Script, and I have no idea with it..
Could you please give me some exmaple to open a server socket and receive the message from android app?
thank you.
If you are looking for websocket support in Lua, try lua-websockets.
For regular sockets, you can use luasocket; the introduction page includes an echo server example working over TCP; this SO answer includes a client example.
I have implemented SignalR support for web application. It works great. The problem I'm dealing now is make it work in non-Azure web farm environment. SignalR supports Windows Azure Service Bus and Redis out of the box. Also there is RabbitMQ implementation on GitHub. All these solutions implement IMessageBus interface.
Based on our current situation we can't use Redis or RabbitMQ. So I have few questions:
1) Is there any alternative solution that uses SQL Server or MSMQ?
2) Is it difficult (possible) to implement your own solution for SQL Server or MSMQ? David's post on SignalR 0.5 (http://weblogs.asp.net/davidfowler/archive/2012/05/02/signalr-0-5.aspx) says they are going to support SQL Server QNS or Service Broker (not SQL Server DB itself) so maybe it's a wrong way at all?
3) Is there a way to work around until this support is implemented? For example, it sounds like the we need to handle state of the connections list between servers. If we know number of nodes and their IPs we can share this information between servers via Web Service calls instead. Does it make any sense?
Damian Edwards appears to have just started working on the SQL scaleout implementation. You can find the details of that implementation here on GitHub and the issue tracking this work can be followed here.
Webmachine seems like a great system to build REST web services, but I know it does not provide websocket compatibility. My question is rather straightforward : What would be a good approach to add websocket capabilities on top of a web service built with webmachine?
I'm running Misultin alongside Webmachine for that exact matter.
For easy use websockets in webmachine I implemented that by changing sources of webmachine (adding support mochiweb_websockets ) and mochiweb (add support secure websockets).
You can download from git full solution (webmachine with websockets support) by this link:
https://github.com/Dryymoon/webmachine.git
And by this link example usage of solution.
Or if want dig a little deeper:
I changed only two files of sources:
1) webmachine_decision_core.erl changed (add support websocket handler).
2) mochiweb_websocket.erl (add support secure websockets and patch existig).
Late answer, but just stumbled upon this, but another option is to run SimpleBridge (https://github.com/nitrogen/simple_bridge), which adds an abstraction layer (conditionally bypassed using webmachines routing system) which adds websocket support to any erlang webserver it supports (includes webmachine).