Blog about things

blogging experiment about hacking

Testing Apollo With Websocket

We now have the apollo broker running on our virtual host and URI on our webserver to hit to generate messages.We want to display those messages near real-time in a web browser on the host machine.

Our setup

  • web server and PHP backend app are running on our virtual machine (IP=10.0.0.10).
  • apache apollo broker is running on the virtual machine.
  • our webapp server will send a test message to tcp://localhost:61613/topic/okcra-api-ops when URI /sendStompMessage is hit.
  • added a firewall rule on virtual machine to allow access to port tcp/61623 where apollo is listening for websocket connections.

web client

Apollo is shipped with example code, one of which is a websockets example. The html page is located at /examples/stomp/websocket/index.html.

We will load that page into our browser, fill in our connection details, and connect to the apollo broker on our virtual hosts. When successful, it will wait and display any new messages appearing in the topic or queue we have registered interest in.

Next, we will hit the URI to have the web server generate a message. We should see that message reflected almost immediately on our test web page.

Here is the test result. Using curl in the terminal window to invoke the URI sent a message to the broker which was displayed on the websocket chat example page. Success!