@knolleary ok thank you i will try this
I know, that is why I suggest you try it to see whether you can connect.
Alternatively install mosquitto-clients on the pi
sudo apt install mosquitto-clients
then in a terminal run
mosquitto_sub -t "#" -h 176.31.nnn.nnn
and see whether it connects. If you have specified username/password in your broker then
mosquitto_sub -t "#" -h 176.31.nnn.nnn -u theuser -P thepwd
@Colin thank you for help but i try (mosquitto_sub -t "#" -h 176.31.nnn.nnn -u theuser -P thepwd and mosquitto_pub -t "#" -h 176.31.nnn.nnn -u theuser -P thepwd) the error is connection was lost
Did you replace the nnn.nnn with your IP and user pwd with your user/pwd?
If so can you post the exact error you get. If it does say 'connection lost' then that suggests it connects but then loses it. That is why the exact message is important.
[Edit] By the way you can't publish to the wildcard topic. You have to specify a particular topic.
the exact msg is error : connection was lost i use mosquitto_sub -h 176.31.n.n -t testTopic and mosquitto_pub -h 176.31.n.n -t testTopic -m "hello world" the result is error : connection was lost
Have you configured mosquitto in the server to expect user/pwd and/or to use TLS?
If not, then now is the time to try and answer the other question I asked some time ago. What does the mosquitto log on the server show?
Another common issue is cloud hosts only export port 80/443 by default for HTTP/S traffic.
@mirou_IoT MQTT uses port 1883 to connect. Have you configured your server to expose that port?
In additional to Colin's questions, have you tried connecting from a different machine such as you own laptop/computer?
@knolleary i configured my server to expose the port 1883 , no i did not try to connect from different machine
@Colin i use the mosquitto_sub -h 176.31.n.n -t testTopic and mosquitto_pub -h 176.31.n.n -t testTopic -m"humidity" the result that i have is connection was lost
I have suggested several times that you look at the mosquitto log, but as far as I can see you have not even acknowledged that I asked.
thank you all for help
it's work good now the problem is the port 1883 i change it and it's connect good