MQTT mosquito

Hi, I’m trying to use mosquitto from a web page from an iframe. I can not connect to the broker from javascript.
When I try from the server it tells me this:

pi@raspberrypi:~ $ mosquitto -v
1546215903: mosquitto version 1.5.5 starting
1546215903: Using default config.
1546215903: Opening ipv4 listen socket on port 1883.
1546215903: Error: Address already in use

But from home assistant I have no problem using mqtt.
Does anyone think why? What can I try?

Thanks and good year

Are you using the built in broker as well?

mosquitto is the MQTT broker.

The error message suggests port 1883 is already used by another process … possibly an existing instance of mosquitto MQTT broker.

To connect to an MQTT broker, you’d use an MQTT client (like mosquitto_sub or mosquitto_pub).

I have home installed in a rasp. I do not have Hass.io. It looks like I could have duplicated the broker so I see home is clearly using another. The issue is how I use from Javascript from an external website the home assistant broker

https://www.eclipse.org/paho/clients/js/

Yes. I have no problem using mqtt with Javascript although I did not try it on this server. If I want to subscribe from command line pull error and if I do from Javascript also.

mosquitto_sub failed to connect because, as suggested by the not authorized message, you are attempting to connect to an MQTT broker (at 192.168.0.2) that requires authentication. You must specify a username and password.

It is true lol.
It works well.
The issue of Javascript will need to install something?

Well, the issues I see are multiple.

You have to modify your mosquitto conf to run websocket, and set it to a port, usually that is 9001. 1883 is for normal mqtt communication.

You need a CLIENT in your JavaScript to connect to the broker.

What exactly are you looking to accomplish here?

Stop posting screen shots of text. Copy and paste has been around for decades.

It was that. Thank you.
I was just listening to port 1883 and not 9001.
Now it works.

Thanks

@nickrout
Sorry. I do not understand by translation that you want to tell me.

I wanted to use the tasmota timer. I wanted to put it inside an iframe but it does not allow non-https addresses.
What I did is copy the html and with javascritp build a json to send by mqtt to a tastmota device.
Individually the port 9001 works but when I use it inside the iframe of home assisstant I have problems.

mqttws31.min.js:979 WebSocket connection to ‘wss://192.168.0.2:9001/ws’ failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

I imagine that I also have to configure certificates in mosquitto. But it’s something I’ll try tomorrow

Surprisingly, HA has timers, you shouldn’t be using any of tha tasmota timer stuff. The idea is that HA should control everything.

Has integration with tastmota? I never found it.

What EXACTLY are you trying to do? The idea here is to let HA control the devices, not force HA to be frontend for other software to control the devices.

I know. But there are things that are not yet. What I want is to configure schedules on off of tastmota sonoff switch from ha. So far as that does not exist.

You can use HA directly for that

1 Like

how? Never seen that I can do that.

You use automations for scheduling things.

What exactly are you using HA for?

The screenshots that is higher up is from the section where I control my aquarium. I also control lights in my house.
Visually I did not see any card that integrates tastmota to be able to configure on off a plug