Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeoutError: timed out #110

Open
theja0473 opened this issue Nov 26, 2021 · 0 comments
Open

TimeoutError: timed out #110

theja0473 opened this issue Nov 26, 2021 · 0 comments

Comments

@theja0473
Copy link

theja0473 commented Nov 26, 2021

I am using same script like below:

import eventlet
import json
from flask import Flask, render_template
from flask_mqtt import Mqtt
from flask_socketio import SocketIO
from flask_bootstrap import Bootstrap
eventlet.monkey_patch()
app = Flask(name)
app.config['TEMPLATES_AUTO_RELOAD'] = True
app.config['MQTT_BROKER_URL'] = 'localhost'
app.config['MQTT_BROKER_PORT'] = 1883
app.config['MQTT_KEEPALIVE'] = 5
app.config['MQTT_TLS_ENABLED'] = False
mqtt = Mqtt(app)
socketio = SocketIO(app)
bootstrap = Bootstrap(app)
@app.route('/')
def index():
return render_template('index.html')
@socketio.on('publish')
def handle_publish(json_str):
data = json.loads(json_str)
mqtt.publish(data['topic'], data['message'])
@socketio.on('subscribe')
def handle_subscribe(json_str):
data = json.loads(json_str)
mqtt.subscribe(data['topic'])
@socketio.on('unsubscribe_all')
def handle_unsubscribe_all():
mqtt.unsubscribe_all()
@mqtt.on_message()
def handle_mqtt_message(client, userdata, message):
data = dict(
topic=message.topic,
payload=message.payload.decode()
)
socketio.emit('mqtt_message', data=data)
@mqtt.on_log()
def handle_logging(client, userdata, level, buf):
print(level, buf)
if name == 'main':
socketio.run(app, host='0.0.0.0', port=5000, use_reloader=True, debug=True)

But getting below error while running script.

Traceback (most recent call last):
File "C:\Users\THJ3KOR\source\repos\FLAK_REST_API\flask_mqtt_websocket.py", line 26, in
mqtt = Mqtt(app)
File "C:\Users\THJ3KOR\Python310\lib\site-packages\flask_mqtt_init_.py", line 104, in init
self.init_app(app)
File "C:\Users\THJ3KOR\Python310\lib\site-packages\flask_mqtt_init_.py", line 183, in init_app
self.connect()
File "C:\Users\THJ3KOR\Python310\lib\site-packages\flask_mqtt_init
.py", line 209, in _connect
res = self.client.connect(
File "C:\Users\THJ3KOR\Python310\lib\site-packages\paho\mqtt\client.py", line 914, in connect
return self.reconnect()
File "C:\Users\THJ3KOR\Python310\lib\site-packages\paho\mqtt\client.py", line 1044, in reconnect
sock = self._create_socket_connection()
File "C:\Users\THJ3KOR\Python310\lib\site-packages\paho\mqtt\client.py", line 3685, in _create_socket_connection
return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
File "C:\Users\THJ3KOR\Python310\lib\site-packages\eventlet\green\socket.py", line 63, in create_connection
raise err
File "C:\Users\THJ3KOR\Python310\lib\site-packages\eventlet\green\socket.py", line 53, in create_connection
sock.connect(sa)
File "C:\Users\THJ3KOR\Python310\lib\site-packages\eventlet\greenio\base.py", line 266, in connect
self._trampoline(fd, write=True, timeout=timeout, timeout_exc=_timeout_exc)
File "C:\Users\THJ3KOR\Python310\lib\site-packages\eventlet\greenio\base.py", line 211, in trampoline
return trampoline(fd, read=read, write=write, timeout=timeout,
File "C:\Users\THJ3KOR\Python310\lib\site-packages\eventlet\hubs_init
.py", line 159, in trampoline
return hub.switch()
File "C:\Users\THJ3KOR\Python310\lib\site-packages\eventlet\hubs\hub.py", line 313, in switch
return self.greenlet.switch()
TimeoutError: timed out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant