Giter Club home page Giter Club logo

Comments (7)

guillaumepotier avatar guillaumepotier commented on July 19, 2024

Hi @bazo

Thanks for using Elephant.io !

We developed Elephant to emit in some of our cron jobs some events. It was not designed to have a persistent connexion in mind. Socket.io has a powerful deconnect / reconnect mechanism implemented (server side AND client side)

We did not re-implemented this, because it was in our opinion not very relevant to persist a connexion in PHP.

What we do is:

connect
authenticate
emit message
disconnect

Why don't you do the same, on some relevant percents, connect and send the progess status ?

from elephant.io.

bazo avatar bazo commented on July 19, 2024

currently i have it like that, because it;s the only way it works.

the problem is it makes the whole process slower,for example an import that took around 0s takes 6s, 40s take 70s, 700s take 750s and so on, all because of opening and closing connections.

i have implemented a workaround that keeps the connection open if the amount of items to import is lower than some number, otherwise it always opens a new connection, emits then closes.

would it be hard to implement the events like socket.io has by myself?

from elephant.io.

gmajoulet avatar gmajoulet commented on July 19, 2024

Maybe that's a silly question, I'm sorry about that, but if you're displaying the progress percentage on the browser, why don't you use the Socket.IO client, which manages persistent connection, reconnection, and so on ?

from elephant.io.

bazo avatar bazo commented on July 19, 2024

i use the sockiet.io client, but that can't be used from php, right? i just think it is a waste of requests, bandwith or other resources, if you need to connect, emit, disconnect every time. if it can be prevented why not do it?

from elephant.io.

guillaumepotier avatar guillaumepotier commented on July 19, 2024

What is in your php.ini configuration file your php script execution timeout ?

I think keeping open the connexion is keeping open a php thread (how is it not blocking with your import ?), and that php thread has a max exec time no ?

from elephant.io.

bazo avatar bazo commented on July 19, 2024

it's run from cli so there's no time limit. the thread is already started by the import, the client doesn't start any new threads.

the client itself is still sending data as if it were connected. i just see a message in socket.io debug that it was disconnected. maybe it's some socket setting that resets the connection and the client doesn't react to that

from elephant.io.

Taluu avatar Taluu commented on July 19, 2024

As it's been a while and the code has been rewritten from scratch, closing this issue

from elephant.io.

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.