You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java OpenTelemetry Agent通过OTLP连接Jaeger报“unexpected end of stream”错误求助

解决OpenTelemetry Java Agent通过OTLP连接Jaeger的协议不匹配问题

问题根源

从Jaeger容器日志可明确定位:Java Agent使用HTTP/1.x协议向仅支持HTTP/2(gRPC)的4317端口发送请求,协议不兼容导致连接失败,出现transport: http2Server.HandleStreams received bogus greeting from client: "POST /v1/metrics HTTP/1."错误。

Jaeger的OTLP端口分工:

  • 4317:OTLP gRPC专属端口(仅支持HTTP/2协议)
  • 4318:OTLP HTTP端口(支持HTTP/1.1协议)

解决方案(二选一即可)

方案1:用gRPC协议连接4317端口

修改otel-jaeger-config.properties配置文件,指定OTLP协议为grpc:

otel.service.name=myservice
otel.exporter.otlp.endpoint=http://localhost:4317
otel.exporter.otlp.protocol=grpc
otel.logs.exporter=none

方案2:改用4318 HTTP端口

保持HTTP/1.1协议,将配置中的端口替换为4318:

otel.service.name=myservice
otel.exporter.otlp.endpoint=http://localhost:4318
otel.exporter.otlp.protocol=http/protobuf
otel.logs.exporter=none

(注:otel.exporter.otlp.protocol=http/protobuf是Java Agent默认值,可省略)

验证步骤

  1. 重启Jaeger容器(确保端口映射正确):
docker run --name jaeger 
  -e COLLECTOR_OTLP_ENABLED=true 
  -p 16686:16686 
  -p 4317:4317 
  -p 4318:4318 
  jaegertracing/all-in-one
  1. 重启Spring Boot应用,检查日志是否不再出现连接错误
  2. 访问http://localhost:16686,查看Jaeger UI是否能接收到myservice的链路数据

内容的提问来源于stack exchange,提问作者John Little

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 03:15:11