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

failed to connect wss #181

Open
icooooler opened this issue Jun 7, 2023 · 1 comment
Open

failed to connect wss #181

icooooler opened this issue Jun 7, 2023 · 1 comment
Labels

Comments

@icooooler
Copy link

  $subscription = [
        'method' => 'SUBSCRIPTION',
        'params' => ['[email protected]@BTCUSDT', '[email protected]@ETHUSDT'],
    ];

    $context = stream_context_create();
    stream_context_set_option($context, 'ssl', 'verify_peer', false);
    stream_context_set_option($context, 'ssl', 'verify_peer_name', false);

    $client = new Client('wss://wbs.mexc.com/ws', [
        'context' => $context, // Attach stream context created above
        'timeout' => 10
    ]);

    $client->text(json_encode($subscription));

    while (true) {

        $data = $client->receive();
        echo $data;
        sleep(1);
    }

I get error:Could not open socket to "wbs.mexc.com:443": stream_socket_client(): Failed to enable crypto (0).

so what should i do to fix it

@icooooler icooooler added the bug label Jun 7, 2023
@sirn-se
Copy link
Contributor

sirn-se commented Jun 7, 2023

@icooooler Your code works just fine for me, even without disabling peer verification. So the problem is probably SSL setup on the machine you're running the client on.

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