Comments (2)
This is how you do it:
mgr = ManagerClass("your", "arguments", "here")
socketio = SocketIO(client_manager=mgr)
All you need to do is pick a manager class that does what you need. I assume the RedisManager
or KombuManager
classes are what makes more sense to adapt it to work with a cluster, but I'm not sure if you can make this work just by adding extra arguments. Worst case you need to create a custom class that inherits from these and makes the necessary changes to work with a cluster.
from flask-socketio.
I pass the manager through client_manager
and it works as it should.
Code:
app.logger.info(f"Connecting SocketIO to redis at {REDIS_HOST}")
url = REDIS_HOST # self.server_options.get('message_queue', None)
channel = "flask-socketio" # self.server_options.pop('channel', 'flask-socketio')
connection_options={"transport_options" : {"master_name":"mymaster"}}
write_only = False # app is None
client_manager = socketio.KombuManager(url=url, channel=channel, write_only=write_only, connection_options=connection_options)
sio = SocketIO(app, client_manager=client_manager, logger=True, engineio_logger=True)
Logs:
[2023-04-26 11:01:25,031] INFO in server: Connecting SocketIO to redis at sentinel://0.0.0.0:26379
Server initialized for eventlet.
h2j59VBXCfZbUIPRAAAA: Sending packet OPEN data {'sid': 'h2j59VBXCfZbUIPRAAAA', 'upgrades': ['websocket'], 'pingTimeout': 20000, 'pingInterval': 25000}
kombu backend initialized.
h2j59VBXCfZbUIPRAAAA: Received packet MESSAGE data 0{}
h2j59VBXCfZbUIPRAAAA: Sending packet MESSAGE data 0{"sid":"cI-uIDemeBQ6rEnlAAAB"}
pubsub message: emit
h2j59VBXCfZbUIPRAAAA: Sending packet MESSAGE data 2["my event",{"data":1}]
pubsub message: emit
h2j59VBXCfZbUIPRAAAA: Sending packet MESSAGE data 2["my event",{"data":2}]
Thanks for your help!
Closing, because there is no need to pass additional args to SocketIO.
from flask-socketio.
Related Issues (20)
- TypeError: <engineio.packet.Packet object at 0xabec08e0> is not a byte HOT 1
- Test cookie handling API changed in Werkzeug 2.3 HOT 1
- Unable to connect to namespaces other than the main namespace HOT 1
- Cannot start multiple threads HOT 1
- Support for once to listen for an event only 1 time (Like official socket.io server has) HOT 1
- Error when using gevent with allow_unsafe_werkzeug HOT 2
- Option to redirect http to https instead of raising errors HOT 1
- Strange Behavior with RabbitMQ and Flask-SocketIO HOT 4
- get_received(namespace=None) does not returns the messages HOT 5
- Add type hints HOT 9
- Socket.IO test client does not run background task HOT 7
- gevent - cannot enter into function. HOT 1
- Multiple SocketIO instances connected to the same Flask server HOT 1
- python-engineio and python-socketio version matching with Flask-SocketIO >= 5.3.0 HOT 1
- Flask-SocketIO cannot run in ws HOT 1
- pyinstaller Packaging error HOT 1
- How do I intercept event events and authenticate them in a unified manner?
- Waiting for client events leads to timeouts
- Sending events in a separate thread with delays does not send HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-socketio.