Jump to content

mqtt connection show TimeoutError: [WinError 10060]

Featured Replies

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

Edited by tobimarsh43
added code

A timeout message at the socket level suggests that your firewall is blocking port 1883.

To check.

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.