How to send an HTTP request without using curl?
2022-05-22
Problem
We are using JWT validation. For some reasons, when testing on staging, we got 401 error:
[GIN] 2022/05/20 - 14:20:57 | 401 | 2.588128ms | 127.0.0.1 | POST "/v1/endpoint"
Troubleshooting
After looking at the source code, we need to set the operation_debug to true to see what caused that error:
2022/05/20 08:31:26 KRAKEND ERROR: [ENDPOINT: /v1/endpoint][JWTValidator] Unable to validate the token: should have a JSON content type for JWKS endpoint
Troubleshooting slow network file transfer
2021-06-25
We have a Hadoop data cluster. Recently, my colleague noticed that data transfer between servers was slow. Not all are slow; only half of them have problems.
The first tool that comes to mind is iperf3. After installing, I run iperf3 -s then iperf3 -c. While other servers have bandwidth > 900 Mbits/sec, the slow ones are just:
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 11.9 MBytes 99.4 Mbits/sec 0 170 KBytes
[ 4] 1.00-2.00 sec 11.1 MBytes 93.3 Mbits/sec 0 204 KBytes
[ 4] 2.00-3.00 sec 10.9 MBytes 91.7 Mbits/sec 0 204 KBytes
[ 4] 3.00-4.00 sec 8.26 MBytes 69.3 Mbits/sec 102 154 KBytes
[ 4] 4.00-5.00 sec 10.9 MBytes 91.8 Mbits/sec 3 157 KBytes
[ 4] 5.00-6.00 sec 10.9 MBytes 91.7 Mbits/sec 0 165 KBytes
[ 4] 6.00-7.00 sec 10.9 MBytes 91.7 Mbits/sec 0 168 KBytes
[ 4] 7.00-8.00 sec 10.9 MBytes 91.7 Mbits/sec 0 173 KBytes
[ 4] 8.00-9.00 sec 10.9 MBytes 91.7 Mbits/sec 0 173 KBytes
[ 4] 9.00-10.00 sec 10.9 MBytes 91.7 Mbits/sec 0 173 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 108 MBytes 90.4 Mbits/sec 105 sender
[ 4] 0.00-10.00 sec 107 MBytes 89.5 Mbits/sec receiver
How a gRPC message uses length-prefixed framing?
2020-05-06
Once we have the encoded data to send to the other end, we need to package the data in a way that other end can easily extract the information. gRPC uses a message framing technique called length-prefixed framing.
Filter gRPC messages:
$ tshark -r grpc.pcapng -Y 'grpc'
Find out a stream: DATA:
216 923.033355 127.0.0.1 → 127.0.0.1 GRPC 108 DATA[1] (GRPC) (PROTOBUF)
and show the packet details:
tshark -r grpc.pcapng -Y "frame.number == 216" -V
How to show all HTTP2 headers using tshark?
2020-05-05
After sniffing with tcpdump, how can I show all HTTP2 header using tshark?
First, find the frame number based on method:
$ tshark -r grpc.pcapng -Y 'http2.headers.path contains "getBook"'
214 923.033174 127.0.0.1 → 127.0.0.1 HTTP2 150 HEADERS[1]: POST /book.BookInfo/getBook
and then show the packet details:
tshark -r grpc.pcapng -Y "frame.number == 214" -V
HyperText Transfer Protocol 2
Stream: HEADERS, Stream ID: 1, Length 85, POST /book.BookInfo/getBook
Length: 85
Type: HEADERS (1)
Flags: 0x04
.... ...0 = End Stream: False
.... .1.. = End Headers: True
.... 0... = Padded: False
..0. .... = Priority: False
00.0 ..0. = Unused: 0x00
0... .... .... .... .... .... .... .... = Reserved: 0x0
.000 0000 0000 0000 0000 0000 0000 0001 = Stream Identifier: 1
[Pad Length: 0]
Header Block Fragment: 8386459162339faaf74e7eb92a94ec4c54dd39faff418b08…
[Header Length: 216]
[Header Count: 8]
Header: :method: POST
Name Length: 7
Name: :method
Value Length: 4
Value: POST
:method: POST
[Unescaped: POST]
Representation: Indexed Header Field
Index: 3
Header: :scheme: http
Name Length: 7
Name: :scheme
Value Length: 4
Value: http
:scheme: http
[Unescaped: http]
Representation: Indexed Header Field
Index: 6
Header: :path: /book.BookInfo/getBook
Name Length: 5
Name: :path
Value Length: 22
Value: /book.BookInfo/getBook
:path: /book.BookInfo/getBook
[Unescaped: /book.BookInfo/getBook]
Representation: Literal Header Field with Incremental Indexing - Indexed Name
Index: 5
Header: :authority: 127.0.0.1:50051
Name Length: 10
Name: :authority
Value Length: 15
Value: 127.0.0.1:50051
:authority: 127.0.0.1:50051
[Unescaped: 127.0.0.1:50051]
Representation: Literal Header Field with Incremental Indexing - Indexed Name
Index: 1
Header: content-type: application/grpc
Name Length: 12
Name: content-type
Value Length: 16
Value: application/grpc
content-type: application/grpc
[Unescaped: application/grpc]
Representation: Literal Header Field with Incremental Indexing - Indexed Name
Index: 31
Header: user-agent: grpc-go/1.24.0
Name Length: 10
Name: user-agent
Value Length: 14
Value: grpc-go/1.24.0
user-agent: grpc-go/1.24.0
[Unescaped: grpc-go/1.24.0]
Representation: Literal Header Field with Incremental Indexing - Indexed Name
Index: 58
Header: te: trailers
Name Length: 2
Name: te
Value Length: 8
Value: trailers
[Unescaped: trailers]
Representation: Literal Header Field with Incremental Indexing - New Name
Header: grpc-client: evans
Name Length: 11
Name: grpc-client
Value Length: 5
Value: evans
[Unescaped: evans]
Representation: Literal Header Field with Incremental Indexing - New Name
Quan Tong