개요

퇴근하다가 궁금해지는건 무슨 일일까?

퇴근하다가 궁금해지는건 무슨 일일까?

gRPC는 HTTP/2를 사용한다고 해서 패킷이 어떻게 생겼는지 궁금해졌다.

다행히도 gRPC 문서에 wireshark 관련 글이 있어서 따라해보자!


Wireshark 설정하기

https://grpc.io/blog/wireshark/

protobuf 검색 경로 설정

Wireshark Preference → Protocols → ProtoBuf → Protobuf Search paths

Wireshark Preference → Protocols → ProtoBuf → Protobuf Search paths

.proto 파일이 위치한 곳에 경로를 설정하고 “Load all Files” 체크합니다.

패킷 캡처하기

Localhost에서 주고받으므로 Loopback으로 지정한 후 패킷 캡처 시작.

$ curl localhost:8080/v1/posts -XGET
$ curl localhost:8080/v1/register -XPOST -H 'Content-Type: application/json' -d "{\\"username\\":\\"journalctl2\\",\\"password\\":\\"aaaabbbb\\"}"

curl 명령어로 gRPC 패킷 캡처하기.

포트 트래픽 유형 설정

image.png

Wireshark에서 서버 측 포트만 등록하기. (8081, 8082)