-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subscribe to a topic fails #195
Comments
one of my suspicions for the reason behind this behaviour is that the keep_alive value is not set when calling self.client.connect_async through locust_plugins. |
Any feedback ? |
Hi! Sorry, I dont use this User, it was written by @ionutab But ”its just Python”, so maybe you can ask on stackoverflow. Maybe strip away some of the locust-specific stuff and ask in paho-mqtt repo instead. |
Hi, @kamyarz-aws a couple of ideas. I'm not sure why you would need to subscribe to a topic in a performance test. However, you can create your own custom MqttUser, copy paste the code from the existing one and then alter the params for connect_async and add a I'm skeptical that that is the reason though. Thanks! class KamyarzMqttUser(User):
abstract = True
host = "localhost"
port = 1883
transport = "tcp"
ws_path = "/mqtt"
tls_context = None
client_cls: typing.Type[MqttClient] = MqttClient
client_id = None
username = None
password = None
protocol = mqtt.MQTTv311
def __init__(self, environment: Environment):
super().__init__(environment)
self.client: MqttClient = self.client_cls(
environment=self.environment, transport=self.transport, client_id=self.client_id, protocol=self.protocol
)
if self.tls_context:
self.client.tls_set_context(self.tls_context)
if self.transport == "websockets" and self.ws_path:
self.client.ws_set_options(path=self.ws_path)
if self.username and self.password:
self.client.username_pw_set(
username=self.username,
password=self.password,
)
self.client.connect_async(
host=self.host,
port=self.port,
keepalive=3600
)
self.client.loop_start() |
I have this script trying to test against an aws iot message broker.
It does successfully connect and publish, however it is unable to subscribe to a topic.
if I place the subscribe to happen on_connect, no failure would be reported.
I see in the codebase of the mqtt user, that there is a comment on line 25 that says
# indicates a failure to subscribe.
Does this mean it is normal for subscribe to fail ??
The same does NOT happen when I use a public message broker like hiveMQ.
The text was updated successfully, but these errors were encountered: