I want to do some tests with gatling and mqtt. There are different plugins for gatling. I decided to use the plugin from jeanadrien because the other plugins I found don't support subscribe actions.
I have implemented a "serverside" mqtt client (the client runs on the same node as the broker and database) in java. The client has the function to subscribe a number from the topic "number". After subscribing the number from the topic the client read with the number datasets from a mongodb. After reading the datasets from the mongodb the client publish the datasets on the topic "data".
I have tested the function with "MQTT Box" as user-client and it works fine as you can see in the following picture. I send the number to topic "number" and subscribe the data from the topic "data". MQTT-Box
Now I want to use gatling with the plugin to make the same scenario. For that I wrote a scala-testscript.
package mqtt
import com.github.jeanadrien.gatling.mqtt.Predef._
import io.gatling.core.Predef._
import scala.concurrent.duration._
class Mqtt extends Simulation {
val mqttConf = mqtt
// MQTT broker
.host("tcp://localhost:1883")
val scn = scenario("MQTT")
.exec(connect)
.exec(subscribe("data").qosExactlyOnce)
.exec(publish("number", "10").qosExactlyOnce)
setUp(scn.inject(atOnceUsers(1))).protocols(mqttConf)
}
While running the test I get this error :
Simulation mqtt.Mqtt started... 10:15:37.310 [ERROR] c.g.j.g.m.a.PublishAction - 'mqttPublish-1' failed to execute: Can't cast value 10 of type class java.lang.String into class [B
But my script is similiar to the examle from git: https://github.com/jeanadrien/gatling-mqtt-protocol/blob/master/src/test/scala/MqttScenarioExample.scala
Maybe the problem is that I have to convert the string in a [Byte] Array ?! How can I fix it?
Additionally I want to check the subscribe result from the topic "data". Similiar to my websocket-script:
.check(wsAwait.within(10 seconds).until(1).regex(""".*"data_id" : 100.0.*"""))
How can I use checks with mqtt?