Giter Club home page Giter Club logo

Comments (7)

Taluu avatar Taluu commented on August 18, 2024

I guess it's because there's a timeout of some sort (it's not a persistent connexion as there's no support for that).

from elephant.io.

valeriy-efimov avatar valeriy-efimov commented on August 18, 2024

@Taluu Hi again=)
I have a problem with your examle
after a couple of hours of work, your example just hangs in place and no longer continues to work. It's like an endless timeout.

$client->read();
script work hangs on this line
I ran my script in the supervisor, but due to the fact that here it just hangs up and does not give any errors, the supervisor does not even restart it.

from elephant.io.

peter279k avatar peter279k commented on August 18, 2024

@valeriy-efimov, if possible, could you provide your sample code that you execute?

And I don't really know about the supervisor you mention.

Thanks.

from elephant.io.

valeriy-efimov avatar valeriy-efimov commented on August 18, 2024

@peter279k

        $client = new Client(new Version2X('https://us-wss.live-rates.com/'));
        $client->initialize();
        $client->emit('key', ['key' => env('LIVE_RATES_KEY')]);
        $tries = 0;
        $need_while = true;
        while ($need_while) {
            if($tries>5){
                $need_while = false;
                continue;
            }
            $r = $client->read();
            $array = json_decode($this->getBetween($r,"[","]"));
            $obj = json_decode($array[1]);

            if (!isset($obj->currency)) {
                var_dump($r);
                print("\n");
                $tries++;
            } else {
                $tries = 0;
                echo("Instrument: {$obj->currency} | Ask: {$obj->ask} | Bid: {$obj->bid}");
                print("\n");

            }
        }
        $client->close();

from elephant.io.

peter279k avatar peter279k commented on August 18, 2024

@valeriy-efimov, thank you for your reply again.

After looking at your code, it seems that you try connecting a remote WebSocket server to get some rate information.

I'm not sure that this problem you mention is caused by remote WebSocket server,

The connection may be closed by remote server.

And I see you use the finite loop to connect server and the loop will leave after trying five times.

It may have possible reason is as follows.

  • The response is not valid for the elephant.io response parser and this causes the reading work is not done.
    I think we can try printing the response to look at what it happens.

This elephant.io I try on socket.io server looks good to me.

And I don't know the request/response behavior on the socket.io server is same as on remote WebSocket server.

from elephant.io.

valeriy-efimov avatar valeriy-efimov commented on August 18, 2024

image
Here is an example of the situation.

The script is incomplete and hung on the line
$r = $client->read();

from elephant.io.

peter279k avatar peter279k commented on August 18, 2024

@valeriy-efimov, sorry. I cannot reproduce issue easily because it seems that this WebSocket provider is private.

And the elephant.io only support socket.io at this moment.

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.