Skip to content
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

Check if connect() connects succesfully or not #191

Open
2 tasks
felipeb95 opened this issue Sep 15, 2021 · 1 comment
Open
2 tasks

Check if connect() connects succesfully or not #191

felipeb95 opened this issue Sep 15, 2021 · 1 comment

Comments

@felipeb95
Copy link

felipeb95 commented Sep 15, 2021

  • [ X ] I have searched for similar issues in this repository, but couldn't find one.
  • [ X ] I have read the README and have a basic understanding how angular works.

I'm submitting a...

  • Regression (a behavior that used to work and stopped working in a new release)
  • Bug report  
  • [ X ] Feature request

Current behavior

Is there a way to check if the function _mqttService.connect() connects successfully or not?

Expected behavior

I'm seeking for a way to call this function and check if my connection works or no. I have an array of credentials for mqtt and I have to try one by one until one of them works.

Minimal working example of the problem with instructions

Code:
MQTT_SERVICE_OPTIONS.push({ hostname: env.mqtt.server, port: env.mqtt.port, protocol: (env.mqtt.protocol === "wss") ? "wss" : "ws", path: '', username: env.mqtt.username, password: env.mqtt.password, clientId: this.clientId }); this._mqttService.connect(MQTT_SERVICE_OPTIONS[0]);

What is the motivation / use case for changing the behavior?

I want to try different credentials (The user will receive a list of credentials in a webservice, and if the first doesn't work of stop working I'll have to connect to the second one

Environment


ngx-mqtt version: 9.0.5


- Broker 

Others:

@sclausen
Copy link
Owner

Isn’t the state Subject on the MqttService what you want?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants