Framework/gRPC

[Error] NotSslRecordException & Http2Exception

잔망루피 2023. 4. 17. 19:22
반응형

Errors

// Client-side
io.grpc.netty.shaded.io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 00001204000000000000037fffffff000400100000000600002000000004080000000000000f0001
// Server-side
io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception: HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 16030100de010000da0303321abadf42e44519a4c99b2002

 

gRPC 클라이언트, 서버에서 에러 로그가 뜬다...

원인 ➡️ 서버가 PLAINTEXT 모드로 실행되는데 클라이언트는 기본값 TLS로 연결을 시도한다.

 

 

🌿 해결방법

가장 쉬운 해결 방법은 클라이언트에서 PLAINTEXT 모드로 연결을 설정해준다.

# client의 application.yml에 추가
# 요청을 보낼 서버명이 membership이면 membership을 넣는다
grpc:
  client:
    {서버명}:
      negotiationType: PLAINTEXT

하지만, 이 방법은 실제 환경에서는 권장하지 않는다!!!(토이 프로젝트라면 뭐 괜찮다~😉)

 

 

✅ 권장하는 방법

# 서버측의 application.properties
grpc.server.security.enabled=true
grpc.server.security.certificateChain=file:certificates/server.crt
grpc.server.security.privateKey=file:certificates/server.key

서버가 TLS 모드로 실행될 수 있도록 설정해준다.

 

 

 

참고 👇

https://yidongnan.github.io/grpc-spring-boot-starter/en/trouble-shooting.html

 

Trouble-Shooting

Spring Boot starter module for gRPC framework.

yidongnan.github.io

 

반응형

'Framework > gRPC' 카테고리의 다른 글

grpcurl  (0) 2023.03.24
gRPC  (1) 2023.03.15