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

$this->conn is not a valid stream resource #14

Closed
ariews opened this issue Mar 10, 2022 · 2 comments · Fixed by #15
Closed

$this->conn is not a valid stream resource #14

ariews opened this issue Mar 10, 2022 · 2 comments · Fixed by #15

Comments

@ariews
Copy link
Contributor

ariews commented Mar 10, 2022

script:

$ cat run.php 
<?php

require __DIR__.'/vendor/autoload.php';

$ck = new \OneCk\Client('tcp://localhost:9000', 'default', '', 'switch');

$ck->__destruct();

$ php run.php 
PHP Warning:  stream_socket_shutdown(): supplied resource is not a valid stream resource in /home/arie/works/onck/vendor/lizhichao/one-ck/src/Client.php on line 81
PHP Warning:  fclose(): supplied resource is not a valid stream resource in /home/arie/works/onck/vendor/lizhichao/one-ck/src/Client.php on line 82

environments:

$ php -v
PHP 7.4.28 (cli) (built: Feb 26 2022 06:29:20) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies

$ grep 'one-ck' composer.json 
        "lizhichao/one-ck": "^0.2.9
@lizhichao
Copy link
Owner

__ destruct() was executed twice __ destruct is a special function that will be called automatically when ` $ck 'is destroyed. You don't need to call it

@ariews
Copy link
Contributor Author

ariews commented Mar 10, 2022

Uh, it seems you're right, I'm confused I install this library on my Laravel project, then I create a client instance from tinker.

$ php artisan tinker          
Psy Shell v0.11.2 (PHP 7.4.28 — cli) by Justin Hileman
>>> use OneCk\Client
>>> $ch = new Client('tcp://localhost:9000', 'default', '', 'switch')
=> OneCk\Client {#3534}
>>> q
Exit:  Goodbye
PHP Fatal error:  Uncaught ErrorException: stream_socket_shutdown() expects parameter 1 to be resource, int given in /home/arie/works/click/vendor/lizhichao/one-ck/src/Client.php:81
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /home/arie/works/click/vendor/lizhichao/one-ck/src/Client.php(81): stream_socket_shutdown()
#2 [internal function]: OneCk\Client->__destruct()
#3 {main}
  thrown in /home/arie/works/click/vendor/lizhichao/one-ck/src/Client.php on line 81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants