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

Socket server cannot catch emitted message from client #367

Closed
renodesper opened this issue Nov 26, 2016 · 7 comments
Closed

Socket server cannot catch emitted message from client #367

renodesper opened this issue Nov 26, 2016 · 7 comments
Labels

Comments

@renodesper
Copy link

I have this flask-angular2 project which use socketio to send message every 5 second from the server after the client send some coordinate to the server. But when the client emit the message, the server can't catch that message. I use custom namespace, but it also happens when I use default namespace (/).

This is how I open the connection to the default namespace:
20161127004647

This is the function to send the message:
20161127004411

My function simply emit the message to the server. I also try to print the message with console.log and it appears successfully:
20161127004434

Now, in the server I have this handler to catch that message:
20161127004330

But the log doesn't print the message nor the string even though flask-socketio received the message:
20161127004233

These are all the packages that I use:

backports.shutil-get-terminal-size==1.0.0
click==6.6
decorator==4.0.10
enum34==1.1.6
eventlet==0.19.0
fake-factory==0.7.2
Flask==0.11.1
Flask-Cors==3.0.2
Flask-JWT==0.3.2
Flask-SocketIO==2.7.1
Flask-SQLAlchemy==2.1
Flask-WTF==0.13.1
gevent==1.1.2
greenlet==0.4.10
gunicorn==19.6.0
ipaddress==1.0.17
ipython==5.1.0
ipython-genutils==0.1.0
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
marshmallow==2.10.3
MySQL-python==1.2.5
pathlib2==2.1.0
pexpect==4.2.1
pickleshare==0.7.4
prompt-toolkit==1.0.8
psutil==4.4.2
ptyprocess==0.5.1
Pygments==2.1.3
PyJWT==1.4.2
python-dateutil==2.6.0
python-engineio==1.0.3
python-socketio==1.6.0
requests==2.11.1
simplegeneric==0.8.1
six==1.10.0
SQLAlchemy==1.1.2
sqlalchemy-datatables==0.4.0
traitlets==4.3.1
wcwidth==0.1.7
Werkzeug==0.11.11
wheel==0.24.0
WTForms==2.1

I also can't catch the "client_connected" message or any other message.
Can you tell me where I'm doing wrong?
I really appreciate your response, thank you very much.

@miguelgrinberg
Copy link
Owner

How is your server side project structure? Are you sure the module that has your bounding_box event handler is imported when the application starts?

@renodesper
Copy link
Author

This is my project structure:
20161127012609

events.py is the only file which has socketio decorator and I already import that file in create_app function. These are some code in my events.py file:
20161127012817

on_bounding_box function also located in events.py.

@miguelgrinberg
Copy link
Owner

With the information you provided I can't really see what the problem is. Sorry.

Can you make a complete example that I can try here that demonstrates the problem? There is obviously something wrong, but it is probably a small detail.

@renodesper
Copy link
Author

renodesper commented Nov 27, 2016

Hi @miguelgrinberg, this is a minimal example for you to test.

@miguelgrinberg
Copy link
Owner

This ended up being a bug on my side. It was caused by having Socket.IO options passed in the constructor, and later calling init_app with more options.

@miguelgrinberg
Copy link
Owner

@renodesper give version 2.8.1 a try please.

@renodesper
Copy link
Author

Awesome, it works as expected now.
Thank you very much for your fast response @miguelgrinberg

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

No branches or pull requests

2 participants