Closed revilon1991 closed 2 years ago
Hey @revilon1991 . Documentation is located here: https://github.com/spiral/roadrunner-docs/blob/master/beep-beep/grpc.md
You used the wrong configuration (from RR1). There is no workers
configuration section. Please, use the configuration from the link above.
This is the correct output: {"address": "tcp://127.0.0.1:6001", "plugins": ["informer", "resetter"]}
This output is from the RPC plugin with registered RPC endpoints. GRPC plugin doesn't have any RPC endpoints, thus, didn't appear in this log message.
@rustatian yes, I saw this doc.
So, I changed my .rr.yaml
:
grpc:
listen: "tcp://localhost:9001"
proto: "service.proto"
tls:
key: "server.crt"
cert: "server.key"
client_auth_type: "no_client_certs"
max_send_msg_size: 50
max_recv_msg_size: 50
max_connection_idle: 0s
max_connection_age: 0s
max_connection_age_grace: 0s
max_concurrent_streams: 10
ping_time: 1s
timeout: 200s
pool:
num_workers: 2
max_jobs: 0
allocate_timeout: 60s
destroy_timeout: 60
but I got a connection error from the client again.
Maybe we have something else?
I would be glad if I can debug that.
but I got a connection error from the client again.
Could you please share this error?
Yes. My client code:
<?php
include "vendor/autoload.php";
$client = new \Service\EchoClient(
'localhost:9001',
[
'credentials' => \Grpc\ChannelCredentials::createSsl(file_get_contents("server.crt")),
]
);
$result = $client->Ping(
new \Service\Message()
)->wait();
var_dump($result[1]->code, $result[1]->details);
and I get:
// int(14)
// string(34) "failed to connect to all addresses"
Also I checked with nmap
what's port is open when the server is running.
# nmap localhost -p9001
PORT STATE SERVICE
9001/tcp closed tor-orport
I guess that directive grpc
not handled because I tried to change keys to a wrong (for ex listen
=> lusten
) and it doesn't give effect (I didn't see any error).
Could you please share your full configuration? (rr.yaml)
yes, of course. cat .rr.yaml
=>
rpc:
enable: true
listen: tcp://127.0.0.1:6001
grpc:
lusten: "tcp://localhost:9001"
workers.command: "php GrpcWorker.php"
proto: "service.proto"
tls:
key: "server.crt"
cert: "server.key"
client_auth_type: "no_client_certs"
max_send_msg_size: 50
max_recv_msg_size: 50
max_connection_idle: 0s
max_connection_age: 0s
max_connection_age_grace: 0s
max_concurrent_streams: 10
ping_time: 1s
timeout: 200s
pool:
num_workers: 2
max_jobs: 0
allocate_timeout: 60s
destroy_timeout: 60
@revilon1991 Where did you find this option: workers.command: "php GrpcWorker.php"
?
I saw this here https://github.com/spiral/app-grpc#running-grpc-server
It's all my tries. Also, I tried like that:
rpc:
enable: true
listen: tcp://127.0.0.1:6001
grpc:
listen: "tcp://localhost:9001"
# workers.command: "php GrpcWorker.php"
proto: "service.proto"
tls:
key: "server.crt"
cert: "server.key"
client_auth_type: "no_client_certs"
max_send_msg_size: 50
max_recv_msg_size: 50
max_connection_idle: 0s
max_connection_age: 0s
max_connection_age_grace: 0s
max_concurrent_streams: 10
ping_time: 1s
timeout: 200s
pool:
num_workers: 2
max_jobs: 0
allocate_timeout: 60s
destroy_timeout: 60
no difference :(
You used RRv1 configuration on the RRv2 binary (I mentioned this).
grpc
configuration is correct.rpc
doesn't have enable
option.server
plugin)You are right. I have progress, but now I see error about CRC:
# ./rr serve
handle_serve_command: Serve error:
endure_start:
endure_serve_internal: Function call error:
endure_call_serve_fn: got initial serve error from the Vertex grpc.Plugin, stopping execution, error: grpc_plugin_serve: WorkerAllocate:
goridge_frame_receive: CRC verification failed
Though I copied config from example.
Do I have to do somthing else?
PS Now my config looks like that:
rpc:
listen: "tcp://127.0.0.1:6001"
server:
command: "php GrpcWorker.php"
relay: "pipes"
relay_timeout: "20s"
grpc:
listen: "tcp://localhost:9001"
proto: "service.proto"
max_send_msg_size: 50
max_recv_msg_size: 50
max_connection_idle: 0s
max_connection_age: 0s
max_connection_age_grace: 0s
max_concurrent_streams: 10
ping_time: 1s
timeout: 200s
pool:
num_workers: 2
max_jobs: 0
allocate_timeout: 60s
destroy_timeout: 60
This is the sample worker: https://github.com/spiral/roadrunner-plugins/blob/master/tests/worker-grpc.php CRC error means, that your worker responded incorrectly.
Keep in mind, that you should use the new package: https://github.com/spiral/roadrunner-grpc
Yes, I use the package spiral/roadrunner-grpc
and content of my worker is identical with https://github.com/spiral/roadrunner-plugins/blob/master/tests/worker-grpc.php
I can show it:
# cat GrpcWorker.php
<?php
/**
* Sample GRPC PHP server.
*/
use Service\EchoInterface;
use Spiral\RoadRunner\GRPC\Server;
use Spiral\RoadRunner\Worker;
require __DIR__ . '/vendor/autoload.php';
$server = new Server(null, [
'debug' => false, // optional (default: false)
]);
$server->registerService(EchoInterface::class, new EchoService());
$server->serve(Worker::create());
The problem might be in some PHP warnings before RR starts for example.
Yes. I saw it when I launch php GrpcWorker.php
Fatal error: Uncaught Error: Class "EchoService" not found in /app/GrpcWorker.php:17
Stack trace:
#0 {main}
thrown in /app/GrpcWorker.php on line 17
I should copy the example files to the project namespace and use those in the worker.
Now I have a strange problem with the port.
handle_serve_command: Serve error:
endure_start:
endure_serve_internal: Function call error:
endure_call_serve_fn: got initial serve error from the Vertex grpc.Plugin, stopping execution, error: grpc_plugin_serve: cannot bind to "localhost:9001": cannot assign requested address
But my port 9001 is not busy. I checked it with nmap
utils and I tried other ports.
If I can increase verbose maybe I will be able to repair it.
@revilon1991 Yes, you can use:
logs:
mode: development
level: debug
ref: https://github.com/spiral/roadrunner-binary/blob/master/.rr.yaml#L57
I add this to my config:
logs:
mode: development
level: debug
output: /var/log/rr_errors.log
It got me such little... :(
/app # ./rr serve
/app # cat /var/log/rr_errors.log
2021-10-31T17:12:37.547Z DEBUG server worker constructed {"pid": 1491}
2021-10-31T17:12:37.594Z DEBUG server worker constructed {"pid": 1495}
That means, that workers started successfully.
It starts and stops at once... I can show you my full flow work:
The RR clearly says that it cannot bind to this address. Check the RR permissions or other running software.
I could resolve this problem. I just changed the directive listen:
# ...
grpc:
listen: "tcp://localhost:9001"
# ...
=>
# ...
grpc:
listen: "tcp://:9001"
# ...
Now it works.
Thank you so much @rustatian. 🤗 I'm very glad.
You are welcome ❤️ Feel free to close the issue 👍🏻
Thank you for your work. I have a problem. Maybe, it isn't a bug, but I seem this kind of issue more matches my problem.
I got the
rr
by documentation, then I ranrr
but I didn't see thatgrpc
server is running. And my client code can't connect togrpc
server. What's wrong?I tried this code:
I expected to see this happen:
Instead, this happened:
The version of RR used:
v2.5.3
The operation system used:
linux
RR configuration file content:
My worker for
grpc
server:My client code:
Errortrace, Backtrace or Panictrace: none