My k6 version is v0.38.3,When I use metadata in the grpc interface, the server cannot obtain the metadata content
Hi @miya.chen,
welcome to the community forum
When I use metadata in the grpc interface
Do you mean the params.metadata? Are you using something similar?
const params = {
metadata: { 'x-my-header': 'k6test' },
tags: { k6test: 'yes' },
};
I see we are covering the common case on our automated tests. It would be useful if you can report more details about your issue. Please, include an anonymized script that you’re using or the relevant parts. If you could include also how you are reading the value on the gRPC server part that would be optimal.
In this way, we should be able to reproduce on our side the same flow.
Note: You’re using an old version of k6, can you try with the latest version and see if you can see the same issue?
This is my script. When I use postman (Version 9.30.4) or grpccurl, I can get correct results, but when I use k6, the server prints an error log: signature error
import grpc from 'k6/net/grpc';
import {check, sleep, group} from 'k6'
const client = new grpc.Client();
export default function () {
const addr = 'cht-asset-exchange-cht-test-6.bdot-devbase.bybit.com:9090'
client.connect(addr, {plaintext: true, reflect: true});
const params = {
metadata: {
"risk-sign-bin": "CgZicm9rZXISFE1UWTFPVEEyTmpVek56WTJOQT09GMCtycCkMCKsAUhzU0h4eThUMXBUT1AycWdGa3VPTVI4TEFTR21BMFJkeVNVUWltYnJoUTVwREZGNXkvNW1saWxJdXlUSGRPMUh2OUc4YnR4bEdndGdVSWdHcFkzekdZbUpYdFl5QVRnalVCenloV29uVG9uNk9MQWxGajUyZkcxUkRuc2Z3cnU3MDZNb1Q3eTZESGQ5c1NEQ2pESzNSRlZOZzNxK0ZiMFRHNXFycW5KRzRxVT0="
}
};
const payload = {
"exchangeSource": "broker",
"userId": "12345",
"exchangeType": 2,
"quoteType": 1,
"applyReqBody": [
{
"fromCoin": "DOGE",
"fromAmount": "10000",
"toCoin": "USDT",
"sourceId": "alan11DOGETOUSDT28"
}
],
"productCode": "alanTest2"
}
const response = client.invoke('api.cht.asset.exchange.ExchangeBizService/exchangeBatchCoinApply', payload, params);
console.log(JSON.stringify(response));
client.close();
}
I have found the reason. The value of “risk-sign-bin” in metadata should be coded by b64and my k6 should be upgraded to 0.4.