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

Get IP address on message #357

Closed
zaanposni opened this issue Sep 26, 2019 · 2 comments
Closed

Get IP address on message #357

zaanposni opened this issue Sep 26, 2019 · 2 comments
Labels

Comments

@zaanposni
Copy link

I know this is kinda a duplicate of #57 but I cannot figure out how your approach works in my setup.

So you said the remote IP would be receivable by using server.environ[sid]
However we are not using a instance of the Server class nor I have access to a sid as far as I know.

My setup (using a normal flask app):

socketio = SocketIO(app, logger=True)

@socketio.on('chat_message')
def handle_message(message):
    ip = x  #TODO
@miguelgrinberg
Copy link
Owner

This is because you are using Flask-SocketIO, while my comment was for python-socketio, the generic server.

In your case, you want to do socketio.server.environ[sid].

@zaanposni
Copy link
Author

Thanks for your quick response. Works.
Keep up the great work!

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