-
-
Notifications
You must be signed in to change notification settings - Fork 894
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
run with SubdomainDispatcher #309
Comments
I think you should be able to use a subdomain dispatcher. You will not be able to start the app using The |
Thanks for the quick reply! Could you please explain your last sentence a little bit?
Are you talking about taking the code from the socketio.run method? I tried doing a couple different things. But i wasn't sure when to call |
So you have a Inside this factory function you create your app, and call Then you will create a subdomain dispatcher, exactly as in the code you posted above. But instead of running |
Nice, thank you for explaining that. I think i understand what you are saying, i hope i can explain my issue. I am using But the I think that was my ultimate problem after digging the other day. I couldn't figure out how to run the socketio server, without first calling |
I don't see any references to To make sure we are talking about the same thing, this is the chunk of code that you need: https://github.com/miguelgrinberg/Flask-SocketIO/blob/master/flask_socketio/__init__.py#L436-L459. The middle part that deals with SSL can probably be removed, unless you care about SSL, of course. |
Oh sorry, you were talking about the Thanks for bearing with me. One last question. Are you saying to just run this section (eventlet part) of the
|
The I think all you need to start the eventlet server is a subset of that code I linked. Assuming you don't care about SSL or the reloader, you just need this:
The |
Perfect, I get it now. Really appreciate your help. Thank you!
|
@miguelgrinberg Hey, sorry one more question please. I am getting a
|
This is a weird one, yes. I did not realize this, but when you say The odd part is that in my examples I create a server, which makes the socket.io code import a bunch of things, including So the proper start up sequence is then:
And I need to make the same change in my examples, so that I don't take advantage of an import that occurs as a side effect. |
You are the man. Thanks again. That was something i probably should have been able to figure out. I was thinking the Hopefully last one. Everything started and seemed great. My connection events fired on both server and client. But for some reason when i do a Very small code, but it looks something like this. As always, thanks for any help. I am super excited about this integration. # I have logging in here and it does join the room successfully
@sio.on('join account')
def account_connect(js):
join_room(js['account_id'])
# later on a non context aware emit to room
# This is received by the listener below when not using the new custom run method
sio.emit('event', {'msg': 'Cool msg'}, room=account_id) // The client
this.sio = io.connect()
this.sio.on('connect', () => this.sio.emit('join account', { account_id: acc.id }))
this.sio.on('event', data => {
console.log('data', data)
}) Because it does work the old way, i was thinking maybe i am missing a important piece in the code i skipped. Flask/sockets are new to me so i am not even sure where to start debugging or i wouldn't be bothering you. |
Add |
Hey, you mean this right? sio = SocketIO(
logger=True,
engineio_logger=True
) This was super weird, and it took me a while to figure it out. I thought i was my other code. All tested with |
Are you saying that just by adding these two logging arguments your application breaks? That would be very odd. |
Lol i know. I spent an hour making sure because i know how stupid it sounds. Also i have some more information that might help. The last log The flow for this demo is -
Both versions work for all steps, except the subdomain version does not send the message You are a saint man. Thank you again. Sure this has probably been frustrating.
|
There's something strange going on with the subdomain test. Did you notice the server was restarted? This line specifically, near the end:
Does that happen every time you run the test? Any idea why the server is restarting? |
Ahh, nice job. I was thinking that it was part of the Would |
That is logged when a server is created, so you have two servers. Are you using the correct one? Sounds like in the |
I am thinking its a bug in my SubdomainDispatcher that i have probably had for months and didn't know it. And trying to use your tool is surfacing my true noob-ness. Thanks for going down this rabbit hole with me. I appreciate it. |
Hey, wondering if there is a way to run flask-socketio with the flask SubdomainDispatcher. Code from http://flask.pocoo.org/docs/0.11/patterns/appdispatch/#dispatch-by-subdomain
The way i am running it now
I can't figure out how to make socketio.run(app) work since i don't new up the app like the normal
app.run()
method.The text was updated successfully, but these errors were encountered: