Can't run grpctest

here is my rpc.js

import grpc from "k6/net/grpc";
import { check } from 'k6';

export let options = {
scenarios: {
    contacts: {
    executor: 'per-vu-iterations',
    vus: 1,
    iterations: 1,
    maxDuration: '1s',
    },
},
};
const client = new grpc.Client();
client.load(
[], 
"coupon.proto",
);
export default () => {  
client.connect("localhost:9999");
const data = {
    id: 20
};
const response = client.invoke("test.Coupon/TestCoupon", data);
check(response, {
    'status is OK': (r) => r && r.status === grpc.StatusOK,
});
console.log(JSON.stringify(response.message));
client.close()
}

and then i get the error

ERRO[0000] GoError: tls: first record does not look like a TLS handshake 

Can someone help me?thinks!

Hi @bobobkb,

have you tried settings plaintext: true in params passed to connect() to see if it works?

By default, grpc client in k6 tries to connect using TLS, and it seems that your server is using a plaintext (insecure) communication channel.

1 Like

it works for me! thinks! :smiley:

1 Like