I am learning mqtt,mosquitto and test on my localhost is work well.
And then,i rent a linux centos 8 machine and install mosquitto, i try to publish a message to that linux broker from my local windows ip. But it always show TimeoutError: [WinError 10060],I have google but still don't know where is the problem?
I have tried to publish from my windows local ip to test.mosquitto.org and subscribe from linux,it's work!!
I have no idea.
publish:
local broker
.\mosquitto_pub -h 192.168.168.100 -p 1883 -t test -m 'hi'
# mosquitto test server
.\mosquitto_pub -h test.mosquitto.org -p 1883 -t test -m 'hi'
subscribe
hi
but,when i change the ip address to IDC Linux ip,it alway show show TimeoutError: [WinError 10060] local publish to IDC linux
.\mosquitto_pub -h 192.168.168.100 -p 1883 -t test -m 'hi'
TimeoutError: [WinError 10060]
use python paho to publish,the same error
import paho.mqtt.client as mqtt
import random
import json
import datetime
import time
'''
ISOTIMEFORMAT = '%m/%d %H:%M:%S'
client = mqtt.Client()
client.connect("192.168.168.100", 1883, 60)
while True:
t0 = random.randint(0, 30)
t1 = random.randint(30, 40)
t = datetime.datetime.now().strftime(ISOTIMEFORMAT)
topic1 = {'Temperature': t0, 'Time': t}
topic2 = {'Temperature': t1, 'Time': t}
print(json.dumps(topic1))
print(json.dumps(topic2))
client.publish("test", json.dumps(topic1))
client.publish("mytopic_2", json.dumps(topic2))
time.sleep(5)
update,maybe is's error
user@Ubuntu:~$ mosquitto -v
1601989020: mosquitto version 1.6.12 starting
1601989020: Using default config.
1601989020: Opening ipv4 listen socket on port 1883.
1601989020: Error: Address already in use
___________________________________
Trainer for https://bit.ly/3nfYiu3