rabbitmq / rabbitmq-web-mqtt

Provides support for MQTT over WebSockets
Other
55 stars 16 forks source link

Web MQTT returning 500 #14

Closed hijklmno closed 7 years ago

hijklmno commented 7 years ago

Hi RabbitMQ Team,

Thank you for your time.

I'm using Paho Javascript client 1.0.1, with rabbitmq-web-mqtt version 3.6.x (obtained from this link). I am unable to connect to rabbitMQ, getting error: WebSocket connection to 'ws://54.212.231.110:15675/ws' failed: Error during WebSocket handshake: Unexpected response code: 500

My node name is rabbit@ip-10-0-0-4, running Ubuntu 14.04 on AWS EC2. I am hitting the box directly (via the box's public IP).

Any ideas? I have attached the logs below.

Below is the log from rabbit@ip-10-0-0-4.log:

=INFO REPORT==== 15-Nov-2016::02:07:55 ===
accepting Web MQTT connection <0.22636.0> (69.43.197.242:52908 -> 10.0.0.4:15675)

=ERROR REPORT==== 15-Nov-2016::02:07:55 ===
Error in process <0.22636.0> on node 'rabbit@ip-10-0-0-4' with exit value: {[{reason,undef},{mfa,{rabbit_web_mqtt_handler,websocket_init,3}},{stacktrace,[{rabbit_mqtt_processor,initial_state,[#Port<0.26152>,none,{amqp_adapter_info,{10,0,0,4},15675,{69,43,197,242},52908,<<37 bytes>>,{'Web MQTT',"N/A"},[{state,running},{ssl,false}]},#Fun<rabbit_web_mqtt_handler.0.57879460>],[]},{rabbit_web_mqtt_handler... 

Below is the log from rabbit@ip-10-0-0-4-sasl.log:

=SUPERVISOR REPORT==== 15-Nov-2016::02:04:30 ===
     Supervisor: {<0.20799.0>,
                                           rabbit_web_mqtt_connection_sup}
     Context:    child_terminated
     Reason:     {[{reason,undef},
                   {mfa,{rabbit_web_mqtt_handler,websocket_init,3}},
                   {stacktrace,
                       [{rabbit_mqtt_processor,initial_state,
                            [#Port<0.25892>,none,
                             {amqp_adapter_info,
                                 {10,0,0,4},
                                 15675,
                                 {69,43,197,242},
                                 52850,
                                 <<"69.43.197.242:52850 -> 10.0.0.4:15675">>,
                                 {'Web MQTT',"N/A"},
                                 [{state,running},{ssl,false}]},
                             #Fun<rabbit_web_mqtt_handler.0.57879460>],
                            []},
                        {rabbit_web_mqtt_handler,websocket_init,3,
                            [{file,"src/rabbit_web_mqtt_handler.erl"},
                             {line,53}]},
                        {cowboy_websocket,handler_init,3,
                            [{file,"src/cowboy_websocket.erl"},{line,131}]},
                        {cowboy_protocol,execute,4,
                            [{file,"src/cowboy_protocol.erl"},{line,442}]}]},
                   {req,
                       [{socket,#Port<0.25892>},
                        {transport,ranch_tcp},
                        {connection,keepalive},
                        {pid,<0.20801.0>},
                        {method,<<"GET">>},
                        {version,'HTTP/1.1'},
                        {peer,{{69,43,197,242},52850}},
                        {host,<<"54.212.231.110">>},
                        {host_info,undefined},
                        {port,15675},
                        {path,<<"/ws">>},
                        {path_info,undefined},
                        {qs,<<>>},
                        {qs_vals,undefined},
                        {bindings,[]},
                        {headers,
                            [{<<"host">>,<<"54.212.231.110:15675">>},
                             {<<"connection">>,<<"Upgrade">>},
                             {<<"pragma">>,<<"no-cache">>},
                             {<<"cache-control">>,<<"no-cache">>},
                             {<<"upgrade">>,<<"websocket">>},
                             {<<"origin">>,<<"http://localhost:8080">>},
                             {<<"sec-websocket-version">>,<<"13">>},
                             {<<"user-agent">>,
                              <<"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36">>},
                             {<<"accept-encoding">>,<<"gzip, deflate, sdch">>},
                             {<<"accept-language">>,<<"en-US,en;q=0.8">>},
                             {<<"sec-websocket-key">>,
                              <<"HCN8uU9Pfou2ZAoHvkpw2g==">>},
                             {<<"sec-websocket-extensions">>,
                              <<"permessage-deflate; client_max_window_bits">>},
                             {<<"sec-websocket-protocol">>,<<"mqttv3.1">>}]},
                        {p_headers,
                            [{<<"sec-websocket-extensions">>,
                              [{<<"permessage-deflate">>,
                                [<<"client_max_window_bits">>]}]},
                             {<<"upgrade">>,[<<"websocket">>]},
                             {<<"connection">>,[<<"upgrade">>]}]},
                        {cookies,undefined},
                        {meta,
                            [{websocket_version,13},
                             {websocket_compress,false}]},
                        {body_state,waiting},
                        {buffer,<<>>},
                        {multipart,undefined},
                        {resp_compress,false},
                        {resp_state,waiting},
                        {resp_headers,[]},
                        {resp_body,<<>>},
                        {onresponse,undefined}]},
                   {opts,[{keepalive_sup,<0.20800.0>}]}],
                  [{cowboy_protocol,execute,4,
                       [{file,"src/cowboy_protocol.erl"},{line,442}]}]}
     Offender:   [{pid,<0.20801.0>},
                  {name,cowboy_protocol},
                  {mfargs,
                   {cowboy_protocol,start_link,
                    [web_mqtt,#Port<0.25892>,ranch_tcp,
                     [{env,
                       [{keepalive_sup,<0.20800.0>},
                        {dispatch,
                         [{'_',[],
                           [{[<<"ws">>],[],rabbit_web_mqtt_handler,[]}]}]}]},
                      {middlewares,
                       [cowboy_router,rabbit_web_mqtt_middleware,
                        cowboy_handler]}]]}},
                  {restart_type,intrinsic},
                  {shutdown,4294967295},
                  {child_type,worker}]

=SUPERVISOR REPORT==== 15-Nov-2016::02:04:30 ===
     Supervisor: {<0.20799.0>,
                                           rabbit_web_mqtt_connection_sup}
     Context:    shutdown
     Reason:     reached_max_restart_intensity
     Offender:   [{pid,<0.20801.0>},
                  {name,cowboy_protocol},
                  {mfargs,
                   {cowboy_protocol,start_link,
                    [web_mqtt,#Port<0.25892>,ranch_tcp,
                     [{env,
                       [{keepalive_sup,<0.20800.0>},
                        {dispatch,
                         [{'_',[],
                           [{[<<"ws">>],[],rabbit_web_mqtt_handler,[]}]}]}]},
                      {middlewares,
                       [cowboy_router,rabbit_web_mqtt_middleware,
                        cowboy_handler]}]]}},
                  {restart_type,intrinsic},
                  {shutdown,4294967295},
                  {child_type,worker}]

Below is the status of my rabbit server:

rabbitmqctl status
Status of node 'rabbit@ip-10-0-0-4' ...
[{pid,8473},
 {running_applications,
     [{rabbitmq_web_mqtt,"RabbitMQ MQTT-over-WebSockets adapter",[]},
      {rabbitmq_management,"RabbitMQ Management Console","3.6.1"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.6.1"},
      {webmachine,"webmachine","1.10.3"},
      {mochiweb,"MochiMedia Web Server","2.13.0"},
      {cowboy,"Small, fast, modular HTTP server.","1.0.3"},
      {cowlib,"Support library for manipulating Web protocols.","1.0.1"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.6.1"},
      {rabbitmq_mqtt,"RabbitMQ MQTT Adapter","3.6.1"},
      {rabbit,"RabbitMQ","3.6.1"},
      {os_mon,"CPO  CXC 138 46","2.2.14"},
      {amqp_client,"RabbitMQ AMQP Client","3.6.1"},
      {rabbit_common,[],"3.6.1"},
      {inets,"INETS  CXC 138 49","5.9.7"},
      {ranch,"Socket acceptor pool for TCP protocols.","1.2.1"},
      {compiler,"ERTS  CXC 138 10","4.9.4"},
      {syntax_tools,"Syntax tools","1.6.12"},
      {ssl,"Erlang/OTP SSL application","5.3.2"},
      {public_key,"Public key infrastructure","0.21"},
      {asn1,"The Erlang ASN1 compiler version 2.0.4","2.0.4"},
      {crypto,"CRYPTO version 2","3.2"},
      {xmerl,"XML parser","1.3.5"},
      {mnesia,"MNESIA  CXC 138 12","4.11"},
      {sasl,"SASL  CXC 138 11","2.3.4"},
      {stdlib,"ERTS  CXC 138 10","1.19.4"},
      {kernel,"ERTS  CXC 138 10","2.16.4"}]},
 {os,{unix,linux}},
 {erlang_version,
     "Erlang R16B03 (erts-5.10.4) [source] [64-bit] [async-threads:64] [kernel-poll:true]\n"},
 {memory,
     [{total,55663576},
      {connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,60672},
      {queue_procs,19328},
      {queue_slave_procs,0},
      {plugins,935400},
      {other_proc,18794648},
      {mnesia,62808},
      {mgmt_db,552968},
      {msg_index,51240},
      {other_ets,1434008},
      {binary,788528},
      {code,27614805},
      {atom,992409},
      {other_system,4356762}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5672,"::"},{mqtt,1883,"::"}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,839062323},
 {disk_free_limit,50000000},
 {disk_free,6722883584},
 {file_descriptors,
     [{total_limit,924},{total_used,3},{sockets_limit,829},{sockets_used,1}]},
 {processes,[{limit,1048576},{used,261}]},
 {run_queue,0},
 {uptime,2688},
 {kernel,{net_ticktime,60}}]
michaelklishin commented 7 years ago

Please post questions to rabbitmq-users or Stack Overflow. RabbitMQ uses GitHub issues for specific actionable items engineers can work on, not questions. Thank you.

michaelklishin commented 7 years ago

The log entry says a function (rabbit_web_mqtt_handler:websocket_init/3) is undefined. Please post full log, your RabbitMQ version and a JS snippet we can use to reproduce to rabbitmq-users.

michaelklishin commented 7 years ago

OK, I see you have posted status and it says RabbitMQ 3.6.1. This plugin was developed after 3.6.1 was released and requires a more recent version (go right up to 3.6.5).

hijklmno commented 7 years ago

I see, thank you @michaelklishin. I will post to rabbitmq-users next time. Will try 3.6.5.

hijklmno commented 7 years ago

Just a follow up, 3.6.5 works beautifully (3.6.1 does not work). Thank you for your help @michaelklishin.