Steem Load Balancer: Fix Invalid Request due to Header Not Set

in Witness Activities16 days ago

Both Load Balancer Nodes for STEEM have been updated:

image.png

Repo: https://github.com/DoctorLai/steem-load-balancer

I've come across this bug - which I need to spend some time debugging:

curl -s -X POST --data '{"jsonrpc":"2.0", "method":"condenser_api.get_account_count", "params":[], "id":1}' https:/
/api.steemyy.com | jq
{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32600,
"message": "Invalid Request",
"data": {
"error_id": "99d35fc4-804e-49a1-9613-98b4a9cdc0ec",
"jussi_request_id": "001102709905755570"
}
}
}

It turns out when -H "content-type:application/json" is not set, the request body is treated as string instead of JSON. Thus, fixing it:

https://github.com/DoctorLai/steem-load-balancer/pull/18/files

I've also add this failure as tests.

## This tests the load balancer by sending a POST request to the server and checking the response
## curl -s --data '{"jsonrpc":"2.0", "method":"condenser_api.get_account_count", "params":[], "id":1}' https://api.steemyy.com | jq
send_request_condenser_api_get_account_count() {    
    resp=$(curl -k -s -m 5 --data '{"jsonrpc":"2.0", "method": "condenser_api.get_account_count", "params": [], "id":1}' http://127.0.0.1:443/)
    echo "Response: $resp"

    ## resp = {"jsonrpc":"2.0","result":1931791,"id":1}
    ## get jsonrpc, result, and id
    resp_jsonrpc=$(echo $resp | jq -r '.jsonrpc')
    resp_result=$(echo $resp | jq -r '.result')
    resp_id=$(echo $resp | jq -r '.id')

    ## check if the response is OK and the version is correct
    ## check if resp_result is a valid number
    if [ "$resp_jsonrpc" != "2.0" ] || [ "$resp_id" != "1" ] || ! [[ "$resp_result" =~ ^[0-9]+$ ]]; then
        echo "send_request_condenser_api_get_account_count failed: $resp"
        return 1
    fi
    echo "send_request_condenser_api_get_account_count passed!"
    return 0
}

Steem Blockchain

Steem to the Moon🚀!

Sort:  
1000026106.png1000026105.png

I will always support you now and vote for @justyy . withness I have voted for two or three witnesses before. I voted for the pennsif.witness first and now I will vote for you. Okay thanks and Good luck for the next. Once again I always support you.

Thank you.

Welcome Dear friend .