This document provides comprehensive testing commands for grpcbin, a gRPC request & response service similar to httpbin but for gRPC.
https://grpc-envoy.qa.akamai.comhttps://grpc-envoy.qa.akamai.comhttp://localhost:50054grpcbin provides multiple test services:
50054This service supports both native gRPC and gRPC-Web protocols:
50054 (grpcbin direct)grpcurl 443 (HTTPS production)curl with custom protobuf encodingWhen using grpcurl to access services through Envoy proxy on port 443, you need to include the x-service-target header:
# List available services (requires x-service-target header)
grpcurl -insecure -H 'x-service-target: grpcbin' \
grpc-envoy.qa.akamai.com:443 list
# List methods in a service
grpcurl -insecure -H 'x-service-target: grpcbin' \
grpc-envoy.qa.akamai.com:443 list grpcbin.GRPCBin
# Describe a service
grpcurl -insecure -H 'x-service-target: grpcbin' \
grpc-envoy.qa.akamai.com:443 describe grpcbin.GRPCBin
All gRPC-Web requests use:
- Content-Type: application/grpc-web
- Accept: application/grpc-web
- x-service-target: grpcbin (for Envoy routing)
Create a helper script to encode gRPC-Web requests:
cat > /tmp/grpcbin_helper.py << 'EOF'
import struct
import sys
def encode_varint(value):
result = []
while value >= 0x80:
result.append((value & 0x7F) | 0x80)
value >>= 7
result.append(value)
return bytes(result)
def encode_int64_field(field_number, value):
tag = (field_number << 3) | 0 # Wire type 0 (varint)
return encode_varint(tag) + encode_varint(value)
def encode_string_field(field_number, value):
string_bytes = value.encode('utf-8')
tag = (field_number << 3) | 2 # Wire type 2 (length-delimited)
return encode_varint(tag) + encode_varint(len(string_bytes)) + string_bytes
def create_grpc_frame(message):
return b'\x00' + struct.pack('>I', len(message)) + message
def create_sum_request(a, b):
message = encode_int64_field(1, a) + encode_int64_field(2, b)
return create_grpc_frame(message)
def create_concat_request(a, b):
message = encode_string_field(1, a) + encode_string_field(2, b)
return create_grpc_frame(message)
def create_hello_request(greeting):
message = encode_string_field(1, greeting)
return create_grpc_frame(message)
def create_empty_request():
return create_grpc_frame(b'')
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python grpcbin_helper.py <command> [args...]", file=sys.stderr)
sys.exit(1)
command = sys.argv[1]
if command == "sum":
if len(sys.argv) != 4:
print("Usage: python grpcbin_helper.py sum <a> <b>", file=sys.stderr)
sys.exit(1)
data = create_sum_request(int(sys.argv[2]), int(sys.argv[3]))
elif command == "concat":
if len(sys.argv) != 4:
print("Usage: python grpcbin_helper.py concat <a> <b>", file=sys.stderr)
sys.exit(1)
data = create_concat_request(sys.argv[2], sys.argv[3])
elif command == "hello":
if len(sys.argv) != 3:
print("Usage: python grpcbin_helper.py hello <greeting>", file=sys.stderr)
sys.exit(1)
data = create_hello_request(sys.argv[2])
elif command == "empty":
data = create_empty_request()
else:
print(f"Unknown command: {command}", file=sys.stderr)
sys.exit(1)
sys.stdout.buffer.write(data)
EOF
chmod +x /tmp/grpcbin_helper.py
Create a helper script to decode gRPC-Web responses:
cat > /tmp/parse_grpc_response.py << 'EOF'
import struct
import sys
def decode_varint(data, pos):
"""Decode a varint from data starting at pos, return (value, new_pos)"""
result = 0
shift = 0
while pos < len(data):
byte = data[pos]
pos += 1
result |= (byte & 0x7F) << shift
if not (byte & 0x80):
return result, pos
shift += 7
return result, pos
def decode_string_field(data, pos):
"""Decode a length-delimited string field"""
length, pos = decode_varint(data, pos)
string_bytes = data[pos:pos+length]
pos += length
try:
return string_bytes.decode('utf-8'), pos
except:
return string_bytes.hex(), pos
def decode_int64_field(data, pos):
"""Decode a varint int64 field"""
value, pos = decode_varint(data, pos)
return value, pos
def parse_grpc_web_response(response_data):
"""Parse gRPC-Web binary response frames"""
if len(response_data) < 5:
print("Response too short")
return
i = 0
frame_count = 0
while i < len(response_data):
if i + 5 > len(response_data):
break
flag = response_data[i]
frame_length = struct.unpack(">I", response_data[i+1:i+5])[0]
i += 5
if i + frame_length > len(response_data):
break
frame_body = response_data[i:i+frame_length]
i += frame_length
if flag == 0: # data frame (uncompressed)
print(f"=== Frame {frame_count} (Data) ===")
decode_message(frame_body)
frame_count += 1
elif flag == 0x80: # trailer frame
print(f"=== Frame {frame_count} (Trailers) ===")
trailer_text = frame_body.decode('utf-8', errors='ignore')
print(trailer_text)
frame_count += 1
def decode_message(data):
"""Attempt to decode a protobuf message"""
pos = 0
fields = {}
while pos < len(data):
if pos >= len(data):
break
# Read tag
tag, pos = decode_varint(data, pos)
field_number = tag >> 3
wire_type = tag & 0x07
if wire_type == 0: # Varint
value, pos = decode_int64_field(data, pos)
fields[field_number] = value
print(f" Field {field_number} (int): {value}")
elif wire_type == 2: # Length-delimited (string or nested message)
value, pos = decode_string_field(data, pos)
fields[field_number] = value
print(f" Field {field_number} (string): {value}")
else:
print(f" Field {field_number}: Unknown wire type {wire_type}")
break
return fields
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python parse_grpc_response.py <response_file>")
print("Example: python parse_grpc_response.py /tmp/sum_response.bin")
sys.exit(1)
response_file = sys.argv[1]
with open(response_file, "rb") as f:
response_data = f.read()
parse_grpc_web_response(response_data)
EOF
chmod +x /tmp/parse_grpc_response.py
Add two integers and return the sum.
grpcurl -plaintext -d '{"a": 42, "b": 58}' \
localhost:50054 addsvc.Add/Sum
grpcurl -plaintext -d '{"a": 100, "b": 250}' \
localhost:50054 addsvc.Add/Sum
Expected Response:
{
"v": "100"
}
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"a": 42, "b": 58}' \
grpc-envoy.qa.akamai.com:443 addsvc.Add/Sum
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"a": 100, "b": 250}' \
grpc-envoy.qa.akamai.com:443 addsvc.Add/Sum
# Encode the request
python3 /tmp/grpcbin_helper.py sum 42 58 > /tmp/sum_request.bin
# Send the request
curl -k -s -X POST https://grpc-envoy.qa.akamai.com/addsvc.Add/Sum \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/sum_request.bin \
--output /tmp/sum_response.bin
# Parse the response
python3 /tmp/parse_grpc_response.py /tmp/sum_response.bin
Expected Output:
=== Frame 0 (Data) ===
Field 1 (int): 100
=== Frame 1 (Trailers) ===
grpc-status:0
grpc-message:
Concatenate two strings and return the result.
grpcurl -plaintext -d '{"a": "Hello", "b": "World"}' \
localhost:50054 addsvc.Add/Concat
grpcurl -plaintext -d '{"a": "gRPC", "b": "bin"}' \
localhost:50054 addsvc.Add/Concat
Expected Response:
{
"v": "HelloWorld"
}
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"a": "Hello", "b": "World"}' \
grpc-envoy.qa.akamai.com:443 addsvc.Add/Concat
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"a": "Test", "b": "Service"}' \
grpc-envoy.qa.akamai.com:443 addsvc.Add/Concat
# Encode the request
python3 /tmp/grpcbin_helper.py concat "Hello" "World" > /tmp/concat_request.bin
# Send the request
curl -k -s -X POST https://grpc-envoy.qa.akamai.com/addsvc.Add/Concat \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/concat_request.bin \
--output /tmp/concat_response.bin
# Parse the response
python3 /tmp/parse_grpc_response.py /tmp/concat_response.bin
Expected Output:
=== Frame 0 (Data) ===
Field 1 (string): HelloWorld
=== Frame 1 (Trailers) ===
grpc-status:0
grpc-message:
Simple unary call that returns a greeting.
grpcurl -plaintext -d '{"greeting": "World"}' \
localhost:50054 hello.HelloService/SayHello
grpcurl -plaintext -d '{"greeting": "Alice"}' \
localhost:50054 hello.HelloService/SayHello
Expected Response:
{
"reply": "hello World"
}
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"greeting": "World"}' \
grpc-envoy.qa.akamai.com:443 hello.HelloService/SayHello
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"greeting": "Bob"}' \
grpc-envoy.qa.akamai.com:443 hello.HelloService/SayHello
# Encode the request
python3 /tmp/grpcbin_helper.py hello "gRPC-Web" > /tmp/hello_request.bin
# Send the request
curl -k -s -X POST https://grpc-envoy.qa.akamai.com/hello.HelloService/SayHello \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/hello_request.bin \
--output /tmp/hello_response.bin
# Parse the response
python3 /tmp/parse_grpc_response.py /tmp/hello_response.bin
Expected Output:
=== Frame 0 (Data) ===
Field 1 (string): hello gRPC-Web
=== Frame 1 (Trailers) ===
grpc-status:0
grpc-message:
Test basic unary RPC with custom message fields.
# Empty request
grpcurl -plaintext -d '{}' \
localhost:50054 grpcbin.GRPCBin/DummyUnary
# With custom message
grpcurl -plaintext -d '{"f_string": "Hello grpcbin!"}' \
localhost:50054 grpcbin.GRPCBin/DummyUnary
Expected Response:
{
"fString": "Hello grpcbin!"
}
# Empty request
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/DummyUnary
# With custom message
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"f_string": "Hello via Envoy!"}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/DummyUnary
Note: Use helper scripts for proper binary encoding. For simple testing, use grpcurl (Method A or B).
Test sending and receiving empty messages.
grpcurl -plaintext -d '{}' \
localhost:50054 grpcbin.GRPCBin/Empty
Expected Response:
{}
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/Empty
# Encode empty request
python3 /tmp/grpcbin_helper.py empty > /tmp/empty_request.bin
# Send the request
curl -k -s -X POST https://grpc-envoy.qa.akamai.com/grpcbin.GRPCBin/Empty \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/empty_request.bin \
--output /tmp/empty_response.bin
# Parse the response
python3 /tmp/parse_grpc_response.py /tmp/empty_response.bin
Get information about the grpcbin service.
grpcurl -plaintext -d '{}' \
localhost:50054 grpcbin.GRPCBin/Index
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/Index
Inspect request headers received by the server.
grpcurl -plaintext -d '{}' \
localhost:50054 grpcbin.GRPCBin/HeadersUnary
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/HeadersUnary
Server streams multiple hello responses (typically 10 messages).
grpcurl -plaintext -d '{"greeting": "Streamer"}' \
localhost:50054 hello.HelloService/LotsOfReplies
Expected Response: (10 messages)
{
"reply": "hello Streamer"
}
{
"reply": "hello Streamer"
}
...
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"greeting": "Streamer"}' \
grpc-envoy.qa.akamai.com:443 hello.HelloService/LotsOfReplies
# Encode the request
python3 /tmp/grpcbin_helper.py hello "Streaming Test" > /tmp/stream_request.bin
# Send the request (note the -N flag for streaming)
curl -k -s -N -X POST https://grpc-envoy.qa.akamai.com/hello.HelloService/LotsOfReplies \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/stream_request.bin \
--output /tmp/stream_response.bin
# Parse the response (contains multiple data frames)
python3 /tmp/parse_grpc_response.py /tmp/stream_response.bin
Expected Output:
=== Frame 0 (Data) ===
Field 1 (string): hello Streaming Test
=== Frame 1 (Data) ===
Field 1 (string): hello Streaming Test
...
=== Frame 10 (Trailers) ===
grpc-status:0
grpc-message:
Note on Streaming:
- The -N flag is critical for streaming: without it, curl buffers the entire response
- Each streamed message appears as a separate data frame
- The final trailer frame indicates the stream has completed successfully
Server automatically streams 10 messages back.
# Basic server stream (returns 10 messages)
grpcurl -plaintext -d '{}' \
localhost:50054 grpcbin.GRPCBin/DummyServerStream
# Server stream with custom data in each message
grpcurl -plaintext -d '{"f_string": "Stream message"}' \
localhost:50054 grpcbin.GRPCBin/DummyServerStream
Expected Response: (10 messages)
{
"fString": "Stream message"
}
{
"fString": "Stream message"
}
...
# Basic server stream (returns 10 messages)
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/DummyServerStream
# Server stream with custom data
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"f_string": "Test streaming"}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/DummyServerStream
Note: Server streaming is supported in gRPC-Web. Use the same pattern as hello.HelloService/LotsOfReplies with proper binary encoding.
Send multiple greetings to the server, which responds with the last one received.
# Stream multiple greetings to the server
grpcurl -plaintext \
-d '{"greeting": "Alice"}' \
-d '{"greeting": "Bob"}' \
-d '{"greeting": "Charlie"}' \
localhost:50054 hello.HelloService/LotsOfGreetings
Expected Response:
{
"reply": "hello Charlie"
}
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"greeting": "Alice"}' \
-d '{"greeting": "Bob"}' \
-d '{"greeting": "Charlie"}' \
grpc-envoy.qa.akamai.com:443 hello.HelloService/LotsOfGreetings
Note: Client streaming is NOT supported in gRPC-Web protocol. Use grpcurl (Method A or B) for client streaming.
Note: This method has implementation issues in some grpcbin versions and may return internal errors. Use hello.HelloService/LotsOfGreetings instead for testing client streaming.
Send multiple greetings and receive responses. Returns the last message sent.
# Send multiple greetings and receive responses
grpcurl -plaintext \
-d '{"greeting": "First"}' \
-d '{"greeting": "Second"}' \
-d '{"greeting": "Third"}' \
localhost:50054 hello.HelloService/BidiHello
Expected Response:
{
"reply": "hello Third"
}
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"greeting": "First"}' \
-d '{"greeting": "Second"}' \
-d '{"greeting": "Third"}' \
grpc-envoy.qa.akamai.com:443 hello.HelloService/BidiHello
Note: Bidirectional streaming is NOT supported in gRPC-Web protocol. Use grpcurl (Method A or B) for bidirectional streaming.
Test bidirectional streaming RPC. Returns the last message sent.
# Send multiple messages and receive response
grpcurl -plaintext \
-d '{"f_string": "Ping 1"}' \
-d '{"f_string": "Ping 2"}' \
-d '{"f_string": "Ping 3"}' \
localhost:50054 grpcbin.GRPCBin/DummyBidirectionalStreamStream
Expected Response:
{
"fString": "Ping 3"
}
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"f_string": "Ping 1"}' \
-d '{"f_string": "Ping 2"}' \
-d '{"f_string": "Ping 3"}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/DummyBidirectionalStreamStream
Note: Bidirectional streaming is NOT supported in gRPC-Web protocol. Use grpcurl (Method A or B).
Here's a comprehensive test script for all working gRPC-Web operations:
#!/bin/bash
# test_grpcbin_grpcweb.sh
echo "=== Testing grpcbin with gRPC-Web ==="
echo
# Test 1: Sum (Unary)
echo "1. Sum: 42 + 58"
python3 /tmp/grpcbin_helper.py sum 42 58 > /tmp/test_sum.bin
curl -k -s -X POST https://grpc-envoy.qa.akamai.com/addsvc.Add/Sum \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/test_sum.bin \
--output /tmp/test_sum_response.bin
python3 /tmp/parse_grpc_response.py /tmp/test_sum_response.bin
echo
# Test 2: Concat (Unary)
echo "2. Concat: 'Hello' + 'World'"
python3 /tmp/grpcbin_helper.py concat "Hello" "World" > /tmp/test_concat.bin
curl -k -s -X POST https://grpc-envoy.qa.akamai.com/addsvc.Add/Concat \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/test_concat.bin \
--output /tmp/test_concat_response.bin
python3 /tmp/parse_grpc_response.py /tmp/test_concat_response.bin
echo
# Test 3: Hello (Unary)
echo "3. Hello: 'gRPC-Web Test'"
python3 /tmp/grpcbin_helper.py hello "gRPC-Web Test" > /tmp/test_hello.bin
curl -k -s -X POST https://grpc-envoy.qa.akamai.com/hello.HelloService/SayHello \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/test_hello.bin \
--output /tmp/test_hello_response.bin
python3 /tmp/parse_grpc_response.py /tmp/test_hello_response.bin
echo
# Test 4: Server Streaming
echo "4. Server Streaming: LotsOfReplies"
python3 /tmp/grpcbin_helper.py hello "Stream" > /tmp/test_stream.bin
curl -k -s -N -X POST https://grpc-envoy.qa.akamai.com/hello.HelloService/LotsOfReplies \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/test_stream.bin \
--output /tmp/test_stream_response.bin
python3 /tmp/parse_grpc_response.py /tmp/test_stream_response.bin
echo
# Test 5: Empty Message
echo "5. Empty Message Test"
python3 /tmp/grpcbin_helper.py empty > /tmp/test_empty.bin
curl -k -s -X POST https://grpc-envoy.qa.akamai.com/grpcbin.GRPCBin/Empty \
-H "Content-Type: application/grpc-web" \
-H "x-service-target: grpcbin" \
-H "Accept: application/grpc-web" \
--data-binary @/tmp/test_empty.bin \
--output /tmp/test_empty_response.bin
python3 /tmp/parse_grpc_response.py /tmp/test_empty_response.bin
echo
echo "=== All Tests Complete ==="
Make it executable and run:
chmod +x test_grpcbin_grpcweb.sh
./test_grpcbin_grpcweb.sh
Test a unary call that returns an empty response.
# Direct gRPC
grpcurl -plaintext -d '{}' \
localhost:50054 grpcbin.GRPCBin/NoResponseUnary
# Via Envoy
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/NoResponseUnary
Test error handling with random errors.
# Direct gRPC
grpcurl -plaintext -d '{}' \
localhost:50054 grpcbin.GRPCBin/RandomError
# Via Envoy
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/RandomError
Test specific error codes.
# Direct gRPC - Request specific error code
grpcurl -plaintext -d '{"code": 5}' \
localhost:50054 grpcbin.GRPCBin/SpecificError
# Via Envoy
grpcurl -insecure -H 'x-service-target: grpcbin' \
-d '{"code": 3}' \
grpc-envoy.qa.akamai.com:443 grpcbin.GRPCBin/SpecificError
Common gRPC Status Codes:
- 0 - OK
- 1 - CANCELLED
- 2 - UNKNOWN
- 3 - INVALID_ARGUMENT
- 4 - DEADLINE_EXCEEDED
- 5 - NOT_FOUND
- 7 - PERMISSION_DENIED
- 14 - UNAVAILABLE
Unary RPCs (7 methods): - ✅ addsvc.Add/Sum - ✅ addsvc.Add/Concat - ✅ hello.HelloService/SayHello - ✅ grpcbin.GRPCBin/DummyUnary - ✅ grpcbin.GRPCBin/Empty - ✅ grpcbin.GRPCBin/Index - ✅ grpcbin.GRPCBin/HeadersUnary
Server Streaming (2 methods): - ✅ hello.HelloService/LotsOfReplies - ✅ grpcbin.GRPCBin/DummyServerStream
Client Streaming (1 method): - ✅ hello.HelloService/LotsOfGreetings
Bidirectional Streaming (2 methods): - ✅ hello.HelloService/BidiHello - ✅ grpcbin.GRPCBin/DummyBidirectionalStreamStream
Note: grpcbin is a testing tool and should not be used in production environments for handling sensitive data.