Code Monkey home page Code Monkey logo

mqtt-proxy's Introduction

mqtt-proxy

This service acts as a front end for mqtt servers peforming preauthentication, load balancing and rate limiting.

setup

Create a table with tokens in it.

CREATE TABLE legends (
	uid int(11) NOT NULL AUTO_INCREMENT,
	mqtt_id varchar(128) COLLATE utf8_bin NOT NULL,
	PRIMARY KEY (uid),
	UNIQUE KEY mqtt_id_UNIQUE (mqtt_id)
) DEFAULT CHARSET=utf8;

CREATE TABLE tokens (
  token_id int(11) NOT NULL AUTO_INCREMENT,
  uid int(11) NOT NULL,
  token varchar(64) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (token_id),
  UNIQUE KEY token_UNIQUE (token)
) DEFAULT CHARSET=utf8;

Configure rabbitmq as a backend for mqtt-proxy by editing or creating /usr/local/etc/rabbitmq/rabbitmq.config.

[{rabbit,        [{tcp_listeners,    {"0.0.0.0", 5672}}]},
 {rabbitmq_mqtt, [{default_user,     <<"guest">>},
                  {default_pass,     <<"guest">>},
                  {allow_anonymous,  true},
                  {vhost,            <<"/">>},
                  {exchange,         <<"amq.topic">>},
                  {subscription_ttl, 1800000},
                  {prefetch,         10},
                  {ssl_listeners,    []},
                  {tcp_listeners,    [2883]},
                  {tcp_listen_options, [binary,
                                        {packet,    raw},
                                        {reuseaddr, true},
                                        {backlog,   128},
                                        {nodelay,   true}]}]}
].

Enable plugins by modifying running the following commands.

rabbitmq-plugins enable rabbitmq_management
rabbitmq-plugins enable rabbitmq_mqtt
rabbitmq-plugins enable rabbitmq_tracing

Restart rabbitmq.

rabbitmqctl stop
rabbitmq-server -detached

Port redirection for 443 -> WS port

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 9000

status

  • Preauthentication supports MySQL at the moment

Licensing

mqtt-proxy is licensed under the MIT License. See LICENSE for the full license text.

mqtt-proxy's People

Contributors

wolfeidau avatar jonseymour avatar

Watchers

James Cloos avatar zhoudianyou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.