Hi,
I am referring the sample script to connect to grpcbin.test.k6.io:9000
, the GRPC server without TLS. However, the connection was failed due to context deadline exceeded
. Could you please help to take a look?
Here is the script I am using:
timport grpc from 'k6/net/grpc';
import { check, sleep } from 'k6';
const client = new grpc.Client();
export default () => {
client.connect('grpcbin.test.k6.io:9000', {
plaintext: true,
reflect:true,
timeout:2000
});
const data = { greeting: 'Bert' };
const response = client.invoke('hello.HelloService/SayHello', data);
check(response, {
'status is OK': (r) => r && r.status === grpc.StatusOK,
});
console.log(JSON.stringify(response.message));
client.close();
sleep(1);
};
Note: connecting to GRPC server grpcbin.test.k6.io:9001
with TLS works fine.
Hi @jasonchu,
Welcome to the community forum
It seems like there was a configuration issue with grpcbin.test.k6.io:9000
, but at this moment, it’s fixed, and the scenario should work.
Please let me know if it’s still not the case,
Cheers
@olegbespalov thanks for fixing the server!
Could you share what config change you made on server side? I actually setup my Java based GRPC server on my local (without TLS), and I can use grpcurl
to send request to my server. However, when I use the k6 grpc client, I got the same context deadline exceeded
error while client.connect
.
In our case, the non-TLS port was not exposed. Basically, in that case, the error “context deadline exceeded” means that the GRPC service is unreachable.
Could you please provide more details about the setup? For example, Is it running inside Docker or on a host machine? Are the client’s options the same as in the script above? Does removing the timeout option from the client also not help?
@olegbespalov thanks for looking into this.
The GRPC server is running on my local without docker, it’s just gradlew bootRun
.
The k6 script is also running on my local.
The k6 script is all the same as I posted, except that I connect it to my local:port.
I’m also able to run grpcurl
to access my GRPC server like below:
grpcurl -plaintext -d @ localhost:6565 <service>/<rpc> <<EOM
{
// request payload
}
EOM
Removing the timeout option does not help…
Corresponding connect command that I used but got context deadline exceeded
client.connect('localhost:6565', {
plaintext: true,
reflect:true
})
That’s interesting
I’m not so familiar with Java, but I tried to make an example of the HelloService, and it works like a charm on my local machine.
Could you please check if this example (repository bellow) works for you?
Thank you so much for trying that out!
I was thinking it may be caused by the GRPC version, but looks like you have been using the latest version in your example repo (same as mine).
I’ll try that out on my local and update in this thread!