Forums

Error at hosting a website which subscribes to mqtt broker

I am using the "broker.hivemq.com" broker to subscribe with mqtt. I am facing issues with the website, as I cannot make it work. I get this error:

2022-01-06 23:41:39,821: Error running WSGI application
2022-01-06 23:41:39,827: ConnectionRefusedError: [Errno 111] Connection refused
2022-01-06 23:41:39,827:   File "/var/www/iulianastroia_pythonanywhere_com_wsgi.py", line 16, in <module>
2022-01-06 23:41:39,827:     from app import app as application  # noqa
2022-01-06 23:41:39,827: 
2022-01-06 23:41:39,827:   File "/home/iulianastroia/mysite/app.py", line 13, in <module>
2022-01-06 23:41:39,827:     mqtt = Mqtt(app)

Is there any possibility to solve it and to host my website?

[edit by admin: formatting]

Free accounts have restricted Internet access, which means that they can only make HTTP and HTTPS requests, and these can only go to sites on our whitelist. That means that an MQTT connection won't work.

Paid accounts have unrestricted Internet access, so that problem would not happen.

Okay, got it. So if I upgrade to the Hacker plan (for example), will the website work?

You'll certainly be able to make the MQTT connection, yes -- and if that's all that the website needs, it will work.

Probably the best way to find out would be to try it -- we have a 30-day money-back guarantee, so if you upgrade and it doesn't work, you can always get the money back.