I have setup a Rifidi Edge Server and have implemented the MTQQ sample app that will publish to the embedded Moquette MTQQ Broker. When I then try to connect to the broker using the mtqqws31.js java script I cannot get a connection. I've used the test HTML found here https://code.google.com/p/moquette-mqtt ... 3754028417 to create the web page, which renders correctly. Of course I updated the host and port to point to localhost:8888. I've also tried countless tweaks to the script to provide various options such as userName and password, but so far I have not been able to discern the correct set of options.
When I start the Rifidi Edge Server, I see the following messages being written to the log, so it appears that web sockets are supported on port 8888:
Web socket server started at port 8888.
Open your browser and navigate to http://localhost:8888/
I also see that the moquette.conf file has:
websocket_port 8888
But when I try to connect, I get:
"NetworkError: 400 Bad Request - http://localhost:8888/mqtt"
and:
Firefox can't establish a connection to the server at ws://localhost:8888/mqtt.
this.socket = new WebSocket(wsurl, ["mqtt"]);
and then:
AMQJSC0001E Connect timed out.
Note that since no version is provided in the sample javascript mentioned above, mqttws31.js will try to connect using subprotocol mqtt first and then try with mqttv3.1. The first two errors above are from subprotocol mqtt which does not appear to be supported. The timeout is from the subprotocol mqttv3.1 attempt which does appear to be supported, but the connection still times out. I used Charles 3.9.3 to try and trace the messages and see what was happening. For the mqttv3.1 attempt I see that the response contains the following. Unfortunately I don't know what "Upgrade websocket" and "Connection Upgrade" mean.
HTTP/1.1 101 Switching Protocols
Upgrade websocket
Connection Upgrade
Sec-WebSocket-Accept HoSEhGLaTLAULVPXiK7FQ2xvyFA=
Sec-WebSocket-Protocol mqttv3.1
Has anyone been able to successfully connect javascript using Web Sockets to the embedded Moquette MQTT Broker? If so, I'd sure love to know how you did it and what I'm doing wrong.
Connecting to the MQTT Broker using a javascript websocket
-
- Posts: 1
- Joined: Thu Feb 12, 2015 5:56 pm
- Organization: Level 3 Communications
Re: Connecting to the MQTT Broker using a javascript websock
I believe this is a known issue with moquette .6 we reported and appears to now be resolved
https://github.com/andsel/moquette/issues/5
We plan to include updated moquette in rifidu 4.0 targeting early spring
U could also update osgi moquette bundLe following instructions on wiki on how to add update third party libraries
Wiki.rifidi.net
https://github.com/andsel/moquette/issues/5
We plan to include updated moquette in rifidu 4.0 targeting early spring
U could also update osgi moquette bundLe following instructions on wiki on how to add update third party libraries
Wiki.rifidi.net
Who is online
Users browsing this forum: No registered users and 3 guests