Skip to content
This repository was archived by the owner on Nov 16, 2020. It is now read-only.

Commit 17b332f

Browse files
committed
Fix crash on SSL connections
Also fixes the example for SSL.
1 parent 1eb4d71 commit 17b332f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

priv/example/index.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
55
<title>RabbitMQ Web MQTT Example</title>
6-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
6+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
77
<script src="mqttws31.js" type="text/javascript"></script>
88
<style>
99
.box {
@@ -90,8 +90,8 @@ <h2>Logs</h2>
9090

9191
var debug = pipe('#second');
9292

93-
var wsbroker = "localhost"; //mqtt websocket enabled broker
94-
var wsport = 15675 // port for above
93+
var wsbroker = location.hostname; //mqtt websocket enabled broker
94+
var wsport = parseInt(location.port) // port for above
9595

9696
var client = new Paho.MQTT.Client(wsbroker, wsport, "/ws",
9797
"myclientid_" + parseInt(Math.random() * 100, 10));
@@ -116,6 +116,10 @@ <h2>Logs</h2>
116116
}
117117
};
118118

119+
if (location.protocol == "https:") {
120+
options.useSSL = true;
121+
}
122+
119123
debug("CONNECT TO " + wsbroker + ":" + wsport);
120124
client.connect(options);
121125

src/rabbit_web_mqtt_app.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ mqtt_init() ->
6969
case get_env(ssl_config, []) of
7070
[] ->
7171
ok;
72-
SSLConf ->
72+
SSLConf0 ->
7373
rabbit_networking:ensure_ssl(),
74-
SSLPort = proplists:get_value(port, SSLConf),
74+
SSLPort = proplists:get_value(port, SSLConf0),
75+
SSLConf = [{connection_type, supervisor}|SSLConf0],
7576

7677
{ok, _} = ranch:start_listener(web_mqtt_secure, get_env(num_ssl_acceptors, 1),
7778
ranch_ssl, SSLConf,

0 commit comments

Comments
 (0)