HiveMQ Swarm setting to specify Websocket listener

Hi,

I am trying out HIveMQ Swarm to verify HiveMQ broker features. I am running HiveMQ broker using the docker image “hivemq/hivemq4”.

I am trying to run the default scenario that comes bundled with “hivemq-swarm/scenario” directory.

When I run the “./hivemq-swarm” command - the default scenario is run and I am able to see the output in the console

But when I change the “port” in the scenario.xml to 8000 - which is the port used by the web-socket listener and run “./hivemq-swarm”, I am able to see the same output when running with port “1883” but the program is not exiting after the last step " INFO - Shutting down agent.". I have to use “CTRL+C” to exit. Are the tests run with the web-socket port? Could you please help me out with a resolution for this.

I would also like to know what is the command to specify the username and password in the scenario.xml if role based authentication is enabled. I tried running “./hivemq-swarm” command on a broker which is enabled with role based authentication. Before running Swarm I verified it requires username and password to connect to broker. I am seeing the same output which I observed when trying to run with port 8000 with web-socket listener i.e the program does not exit after the line " INFO - Shutting down agent." and I have to manually exit the program.

Regards,
Harsha

Hi @Harsha,

HiveMQ Swarm doesn’t support web sockets yet, so just changing port will not work as Swarm will still try to open a normal TCP connection.
That the agents are not stopping correctly seems to be a side effect of that, this needs further investigation on our side.

For how to add username and password I will link you to the documentation:
https://www.hivemq.com/docs/swarm/latest/swarm/extensions.html#standard-security

Greetings,
Michael from the HiveMQ team

Thank you Michael.

Regards,
Harsha

Hi Michael,

I am getting the following error when I try to set the username and password in the “scenario.xml”

< connect broker=“b1” credentials="myusername:mypassword "/ >

“myusername” and “mypassword” are not the actual username and password.

Following the output when I run “hivemq-swarm”

2021-05-25 21:38:34,566 INFO - Scenario data distributed.
2021-05-25 21:38:34,568 INFO - Scenario in progress: Stage with id ‘s1’ (1/3).
2021-05-25 21:38:34,639 WARN - Could not parse credentials. Proceeding with empty credentials.
com.hivemq.swarm.standard.security.CredentialsAdapter$InvalidCredentialsException: could not parse Base64 String: myusername:mypassword
at com.hivemq.swarm.standard.security.CredentialsAdapter.parseAuthProperty(CredentialsAdapter.java:67)
at com.hivemq.swarm.standard.security.CredentialsAdapter.parse(CredentialsAdapter.java:37)
at com.hivemq.swarm.standard.security.SecurityExtensionMain.lambda$extensionMain$0(SecurityExtensionMain.java:31)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
at com.hivemq.swarm.standard.security.SecurityExtensionMain.lambda$extensionMain$1(SecurityExtensionMain.java:28)
at r.a.a(Unknown Source)
at r.a.a(Unknown Source)
at r.a.a(Unknown Source)
at r.a.a(Unknown Source)
at r.g.a(Unknown Source)
at ac.c.a(Unknown Source)
at ac.c.channelRead(Unknown Source)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
2021-05-25 21:38:34,868 INFO - Scenario in progress: Stage with id ‘s2’ (2/3).
2021-05-25 21:38:34,877 INFO - Scenario in progress: Stage with id ‘s3’ (3/3).
2021-05-25 21:38:34,882 INFO - Agent localhost/127.0.0.1:3881 connection lost.
2021-05-25 21:38:34,893 INFO - Scenario finished.
2021-05-25 21:38:34,893 INFO - Connection to Commander lost.
2021-05-25 21:38:34,893 INFO - Closed connection to Agent localhost/127.0.0.1:3881
2021-05-25 21:38:34,922 INFO - Resetting agent metrics.
2021-05-25 21:38:34,933 INFO - Shutting down agent.

It seems you put the password in plaintext into the credentials attribute, but it must be encoded as described in the docu:

The password must be a Base64 encoded string. In the following example, `-n` prevents addition of a new line in the password that can interfere with proper detection of the credential:

Example command prompt to create a Base64 encoded password:

echo -n "my-desired-password" | base64
bXktZGVzaXJlZC1wYXNzd29yZA==

So your credentials field should look like this:

credentials="myusername:bXlwYXNzd29yZA=="

But yeah I can see the issue as the documentation example uses plaintext, I will forward an improvement for that.

Greetings,
Michael

Thank you Michael.

Regards,
Harsha

Hi Michael,

I tested with the “Base64 encoded password” and the scenario is executing and the agent is stopping correctly.

I want a small clarification. If some test cases fail or a step fails to execute in the scenario, how would I come to know that something has failed ? Currently the only indication seems to be the agents not stopping correctly after scenario is run.

Regards,
Harsha