Giter VIP home page Giter VIP logo

Comments (9)

miguelgrinberg avatar miguelgrinberg commented on May 18, 2024

In the connect event handler you can return False to reject a connection. As far as disconnecting from the server, I'll have to see how if the Socket.IO protocol allows that, I don't think I've seen a way to do that.

from python-socketio.

tito avatar tito commented on May 18, 2024

Disconnect (in my case) is require also in others function that the connect (i don't have all the users information during the initial connection, only after the auth process.).

So returning False is not enough :)

from python-socketio.

miguelgrinberg avatar miguelgrinberg commented on May 18, 2024

Yes, I agree that disconnect can be useful. I just couldn't find how to implement it, need to read the js client code more carefully to see what can I send it to close a connection, or maybe just fake it, which is to keep it open but don't let any messages in or out.

from python-socketio.

miguelgrinberg avatar miguelgrinberg commented on May 18, 2024

This is now available. Closing.

from python-socketio.

QuingZ avatar QuingZ commented on May 18, 2024

Just wondering how it is implemented eventually, closing the socket connection or faking disconnect?
I am using python-socketio-1.6.0 to setup a server, and facing a problem that the tcp socket are stilled in ESTAB status after invoking socketio.Server.disconnect(). Not sure it is related to this issue or not?

Thanks.

from python-socketio.

miguelgrinberg avatar miguelgrinberg commented on May 18, 2024

@QuingZ This discussion was regarding disconnecting from the client. Disconnecting from the server has been implemented long ago and as far as I know works fine. If you try the example in this app, there is a disconnect button that triggers a server-initiated disconnection.

from python-socketio.

QuingZ avatar QuingZ commented on May 18, 2024

I am using python-socketio-client to connect to server. After socketio.disconnect() is invoked from server, the client can receive "disconnect" message. However, when checking the socket connection by "ss -at", I found that the socket is not closed unless the client process is closed or terminated. My question is that, does disconnecting from the server close the tcp socket, or just keep the socket open but doesn't let any messages in or out? Thanks.

from python-socketio.

miguelgrinberg avatar miguelgrinberg commented on May 18, 2024

That really depends on the WebSocket implementation. This package is not managing the connection at the socket level, it relies on a base WebSocket implementation to do that, and there are currently three of these that are supported. I guess it is possible that when the connection ends there is no proper cleanup of the underlying socket, but that would be something to investigate on the particular WebSocket implementation you are using (eventlet, gevent or uwsgi).

from python-socketio.

QuingZ avatar QuingZ commented on May 18, 2024

I see. I am using eventlet, seems it doesn't close socket properly. I will do same research on it, hopefully can find something.
Thanks for your help!

from python-socketio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.