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

Error found on the example page of the document #89

Closed
woodrex83 opened this issue Mar 5, 2024 · 0 comments · Fixed by #94
Closed

Error found on the example page of the document #89

woodrex83 opened this issue Mar 5, 2024 · 0 comments · Fixed by #94

Comments

@woodrex83
Copy link

https://sabuhish.github.io/fastapi-mqtt/example/

The mqtt variable is undefined in the file. It should be replaced with fast_mqtt

from fastapi_mqtt.fastmqtt import FastMQTT
from fastapi import FastAPI
from fastapi_mqtt.config import MQTTConfig

app = FastAPI()

mqtt_config = MQTTConfig()

fast_mqtt = FastMQTT(config=mqtt_config)

fast_mqtt.init_app(app)

# Should be fast_mqtt here
@mqtt.on_connect()
def connect(client, flags, rc, properties):
    mqtt.client.subscribe("/mqtt") #subscribing mqtt topic
    print("Connected: ", client, flags, rc, properties)
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

Successfully merging a pull request may close this issue.

1 participant