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

something wrong #52

Closed
samplecms opened this issue Nov 28, 2016 · 1 comment
Closed

something wrong #52

samplecms opened this issue Nov 28, 2016 · 1 comment
Labels

Comments

@samplecms
Copy link

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'First parameter must be a valid stream resource' in /Library/WebServer/Documents/www/comm/weixin/vendor/react/stream/src/Stream.php:40 Stack trace: #0 /Library/WebServer/Documents/www/comm/weixin/modules/chart/home.php(14): React\Stream\Stream->__construct('STDOUT', Object(React\EventLoop\StreamSelectLoop)) #1 [internal function]: modules\chart\home->index() #2 /Library/WebServer/Documents/www/comm/weixin/core/router.php(414): call_user_func_array(Array, Array) #3 /Library/WebServer/Documents/www/comm/weixin/core/router.php(391): router->load_route('modules\chart\h...', 'index', Array) #4 /Library/WebServer/Documents/www/comm/weixin/core/router.php(315): router->exec() #5 /Library/WebServer/Documents/www/comm/weixin/public/index.php(50): router::run() #6 {main} thrown

code id here

namespace modules\chart; use React\EventLoop\Factory; use React\Socket\Server; use React\Stream\Stream; class home{
public function index(){
	
	$loop = Factory::create();

	$client = stream_socket_client('tcp://127.0.0.1:1337');
	$conn = new  Stream($client, $loop);
	$conn->pipe(new Stream(STDOUT, $loop));
	$conn->write("Hello World!\n");

	$loop->run();


}
public function background(){
	$loop = Factory::create();

	$socket = new Server($loop);
	$socket->on('connection', function ($conn) {
	    $conn->write("Hello there!\n");
	    $conn->write("Welcome to this amazing server!\n");
	    $conn->write("Here's a tip: don't say anything.\n");

	    $conn->on('data', function ($data) use ($conn) {
	        $conn->close();
	    });
	});
	$socket->listen(1337);

	$loop->run();


}

}

@clue clue added the question label Nov 28, 2016
@clue
Copy link
Member

clue commented Nov 28, 2016

I can only assume your error log is either incomplete (error_reporting=-1 ?) or does not match with the code you've provided? Either way, the error is from the stream component and has little to do with this socket server.

new Stream(STDOUT, $loop);

I hope this helps 👍

@clue clue closed this as completed Nov 28, 2016
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