-
-
Notifications
You must be signed in to change notification settings - Fork 413
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
[🐛 BUG]: Failed to call goridge in the swoole coroutine #1951
Comments
Hey @shellphy 👋 I'm not familiar with Swoole, but it looks like that it tries to send both request via the same RPC connection. I'm not sure what is All RPC connections (not exactly Goridge) should be consecutive, and I'm not sure, these |
It's not the same connection. I tried to print out the rpc object: \Co\run(function () {
go(function () {
$rpc = new Goridge\RPC\RPC(
Goridge\Relay::create('tcp://127.0.0.1:6001')
);
var_dump($rpc);
echo $rpc->call("App.Hi", "Antony");
});
go(function () {
$rpc = new Goridge\RPC\RPC(
Goridge\Relay::create('tcp://127.0.0.1:6001')
);
var_dump($rpc);
echo $rpc->call("App.Hi", "Antony");
});
sleep(10);
}); response:
|
It would be nice if you'd try the following:
I just want to check, if that is something Swooly related. |
I just debugging, in the vendor/spiral/goridge/SRC/RPC/RPC. PHP 88 lines of print log: public function call(string $method, $payload, $options = null)
{
$this->relay->send($this->packFrame($method, $payload));
// wait for the frame confirmation
$frame = $this->relay->waitFrame();
if (\count($frame->options) !== 2) {
throw new RPCException('Invalid RPC frame, options missing');
}
var_dump($frame);
var_dump(self::$seq);
if ($frame->options[0] !== self::$seq) {
throw new RPCException('Invalid RPC frame, sequence mismatch');
}
self::$seq++;
return $this->decodeResponse($frame, $options);
} The results are as follows:
So I think the problem is that the $seq variable is static: private static int $seq = 1; Because in swoole's coroutine environment, static variables are shared because they are still the same process |
Nice, thanks 👍 |
You may try to send a fix 😉 |
I think it's possible to modify the handling here a little bit to make it compatible with swoole coroutines. It is better to put a patch on spiral/goridge:3.2.0 because our php environment is 7.4, thank you |
Yeah, sure, you may send a patch for review and link to this issue. |
I have just submitted a request, and I feel that there is no problem in my test. All testcases have passed, and there is no problem in the test in swoole |
Thank you @shellphy 👍 |
Fixed by: roadrunner-php/goridge#30, thanks @shellphy 👍 |
No duplicates 🥲.
What happened?
Since swoole has been used in our project, we did not directly use the main roadrunner program. Recently, we found your subproject goridge, and tried to call golang methods in swoole coroutines.
However, the issue submission function is not enabled in the goridge project, so issues are submitted here
My test code is as follows:
Both requests are sent to golang, and the result is that the first call is typed correctly, and the second call reports an error:
Hello, Antony!
PHP Fatal error: Uncaught Spiral\Goridge\RPC\Exception\RPCException: Invalid RPC frame, sequence mismatch in /var/www/vendor/spiral/goridge/src/RPC/RPC.php:89
I'm using php7.4, spiral/goridge:3.2.0
Relevant log output
No response
The text was updated successfully, but these errors were encountered: