RabbitMQ MQTT WSS Problem

237 views
Skip to first unread message

Approximately Zero

unread,
Oct 17, 2019, 1:15:17 AM10/17/19
to rabbitmq-users
Hi there, my main purpose is to enable my Web MQTT TLS.
Firstly, I test it via RabbitMQ management.

[{rabbitmq_management,
  [{listener, [{port,     15671},
               {ssl,      true},
               {ssl_opts, [{cacertfile, "D:\\ssl\\cacert.pem"},
                           {certfile,   "D:\\ssl\\cert2.pem"},
                           {keyfile,    "D:\\ssl\\key2.pem"},
                           {password,   "changeme"}]}
              ]}
  ]}
].

And when I access https://domain:15671 it works perfectly with TLS enabled.

Then I moved to RabbitMQ Web MQTT config

[
  {rabbitmq_web_mqtt,
      [{ssl_config, [{port,       15673},
                     {backlog,    1024},
                     {cacertfile, "D:\\ssl\\cacert.pem"},
                     {certfile,   "D:\\ssl\\cert2.pem"},
                     {keyfile,    "D:\\ssl\\key2.pem"},
                     {password,   "changeme"}
                    ]}]}
].

It shows no error, but when I test it using a simple Node JS script, it shows no response.

const mqtt = require('mqtt')

const rmq = mqtt.connect('wss://domain:15673/ws', {
    username: '/test:test',
    password:  'test',
    protocolId: 'MQTT',
    keepalive: 1,
    reconnectPeriod: 100 * 1
  })

  rmq.on('connect'function () {
    rmq.subscribe('sdf'function (err) {
      if (!err) {
        rmq.publish('sdf''Hello mqtt')
      }
    })
  })
   
  rmq.on('message'function (topicmessage) {
    // message is Buffer
    console.log(message.toString())
    rmq.end()
  })

Otherwise, if I change the url to ws://domain:15675/ws, it will works.
I've enable the port anyway.

Here's my rabbitmqctl status:

[{pid,114008},
 {running_applications,
     [{rabbitmq_web_mqtt_examples,"Rabbit WEB-MQTT - examples","3.7.10"},
      {rabbitmq_web_mqtt,"RabbitMQ MQTT-over-WebSockets adapter","3.7.10"},
      {rabbitmq_management,"RabbitMQ Management Console","3.7.10"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.7.10"},
      {rabbitmq_web_stomp,"Rabbit WEB-STOMP - WebSockets to Stomp adapter",
          "3.7.10"},
      {rabbitmq_stomp,"RabbitMQ STOMP plugin","3.7.10"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.7.10"},
      {rabbitmq_mqtt,"RabbitMQ MQTT Adapter","3.7.10"},
      {rabbit,"RabbitMQ","3.7.10"},
      {cowboy,"Small, fast, modern HTTP server.","2.6.1"},
      {amqp_client,"RabbitMQ AMQP Client","3.7.10"},
      {rabbit_common,
          "Modules shared by rabbitmq-server and rabbitmq-erlang-client",
          "3.7.10"},
      {ranch,"Socket acceptor pool for TCP protocols.","1.7.1"},
      {ssl,"Erlang/OTP SSL application","9.1"},
      {public_key,"Public key infrastructure","1.6.4"},
      {asn1,"The Erlang ASN1 compiler version 5.0.8","5.0.8"},
      {mnesia,"MNESIA  CXC 138 12","4.15.5"},
      {inets,"INETS  CXC 138 49","7.0.3"},
      {recon,"Diagnostic tools for production use","2.3.6"},
      {os_mon,"CPO  CXC 138 46","2.4.7"},
      {xmerl,"XML parser","1.3.18"},
      {cowlib,"Support library for manipulating Web protocols.","2.7.0"},
      {jsx,"a streaming, evented json parsing toolkit","2.9.0"},
      {crypto,"CRYPTO","4.4"},
      {lager,"Erlang logging framework","3.6.5"},
      {goldrush,"Erlang event stream processor","0.1.9"},
      {compiler,"ERTS  CXC 138 10","7.3"},
      {syntax_tools,"Syntax tools","2.1.6"},
      {sasl,"SASL  CXC 138 11","3.3"},
      {stdlib,"ERTS  CXC 138 10","3.7"},
      {kernel,"ERTS  CXC 138 10","6.2"}]},
 {os,{win32,nt}},
 {erlang_version,
     "Erlang/OTP 21 [erts-10.2] [64-bit] [smp:6:6] [ds:6:6:10] [async-threads:64]\n"},
 {memory,
     [{connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,14144},
      {queue_procs,102420},
      {queue_slave_procs,0},
      {plugins,1070240},
      {other_proc,43027224},
      {metrics,220660},
      {mgmt_db,177312},
      {mnesia,116944},
      {other_ets,3025872},
      {binary,289824},
      {msg_index,89664},
      {code,28240635},
      {atom,1172689},
      {other_system,12169044},
      {allocated_unused,17827904},
      {reserved_unallocated,0},
      {strategy,rss},
      {total,[{erlang,89716672},{rss,107544576},{allocated,107544576}]}]},
 {alarms,[]},
 {listeners,
     [{clustering,25672,"::"},
      {amqp,5672,"::"},
      {amqp,5672,"0.0.0.0"},
      {mqtt,1883,"::"},
      {mqtt,1883,"0.0.0.0"},
      {stomp,61613,"::"},
      {stomp,61613,"0.0.0.0"},
      {'http/web-stomp',15674,"::"},
      {'http/web-stomp',15674,"0.0.0.0"},
      {https,15671,"::"},
      {https,15671,"0.0.0.0"},
      {'http/web-mqtt',15675,"::"},
      {'http/web-mqtt',15675,"0.0.0.0"},
      {'https/web-mqtt',15673,"::"},
      {'https/web-mqtt',15673,"0.0.0.0"},
      {http,15670,"::"},
      {http,15670,"0.0.0.0"}]},
 {vm_memory_calculation_strategy,rss},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,6832383590},
 {disk_free_limit,50000000},
 {disk_free,1724728987648},
 {file_descriptors,
     [{total_limit,8092},
      {total_used,6},
      {sockets_limit,7280},
      {sockets_used,0}]},
 {processes,[{limit,1048576},{used,667}]},
 {run_queue,1},
 {uptime,10},
 {kernel,{net_ticktime,60}}]

Any ideas? Thank you.
Reply all
Reply to author
Forward
0 new messages