GithubHelp home page GithubHelp logo

Comments (6)

almarklein avatar almarklein commented on August 11, 2024 2

That error originates here:

flexx/flexx/app/_app.py

Lines 601 to 612 in 7461524

def connect_client(self, ws, name, session_id, cookies=None):
""" Connect a client to a session that was previously created.
"""
_, pending, connected = self._appinfo[name]
# Search for the session with the specific id
for session in pending:
if session.id == session_id:
pending.remove(session)
break
else:
raise RuntimeError('Asked for session id %r, but could not find it' %
session_id)

An incoming connection asks the manager to find the corresponding session. In this case it fails, because it looks in the pending sessions, and it's not there.

The session lifetime has a few stages:

STATUS = new_type('Enum', (), {'PENDING': 1, 'CONNECTED': 2, 'CLOSED': 0})

I think we'd need to add another stage, maybe LOST, from which we can reconnect. The manager will also have to keep track of lost sessions in its _appinfo data structure. Though we'd also need a mechanism to purge LOST sessions once they're lost for too long.

I hope this helps ...

from flexx.

almarklein avatar almarklein commented on August 11, 2024 1

I'm not sure, but it could be worth a try ...

from flexx.

almarklein avatar almarklein commented on August 11, 2024

Websockets are indeed more susceptible to connection problems. Technically it should be possible to restore the connection, but I fear that would involve substantial changes to the Flexx internals, because the session is very much tied to the websocket connection right now ...

from flexx.

matkuki avatar matkuki commented on August 11, 2024

No problem, was just wondering if there was a simple workaround.
Thanks for the information.

from flexx.

matkuki avatar matkuki commented on August 11, 2024

Hey @almarklein ,
I looked at some of the source and there are quite a few self.ws or self._ws references.
If I would update all of those references with a new WebSocket when on_ws_close (flexx/app/_clientcore.py line 347) is called, would that work?

from flexx.

matkuki avatar matkuki commented on August 11, 2024

Hey @almarklein

I tried a bit of fiddling around, but now I'm getting the error Asked for session id X, but could not find it when trying to reconnect the socket.
My main problem is that I do not have an idea of how the websocket initialization chain is processed. Could you give me a point-by-point description of the websocket initialization order of the methods needed to initialize and then communicate with the JS side?

Thanks

from flexx.

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.