IronPDF Azure 컨테이너에서 gRPC 연결 오류
IronPDF가 Azure Container Instances 또는 Azure App Service의 Docker 컨테이너 내에 배포될 때, 애플리케이션과 IronPDF 엔진 간의 gRPC 통신이 실패할 수 있습니다. 이 오류는 주로 컨테이너가 유휴 상태이거나 재시작된 후, 또는 gRPC 채널이 재시도 로직으로 설정되지 않았을 때 발생합니다.
Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="failed to connect to all addresses")
Status(StatusCode="Unknown", Detail="Stream removed")
Azure 컨테이너 환경에서 유휴 기간 동안 컨테이너를 종료하거나 재활용할 수 있기 때문에 이러한 오류가 발생합니다. gRPC 채널에 재시도 정책이 없으면 단일 연결이 끊어져서 즉시 실패하게 되며, 다시 연결을 시도하지 않습니다. HTTP/2 스트림 종료 및 플랫폼 특정 채널 설정 불일치 또한 이러한 오류를 유발할 수 있습니다.
해결책
1. 컨테이너 재시작 정책 항상으로 설정
Azure Container Instances에서는 재시작 정책을 Always으로 설정하십시오. Azure App Service에서는 Consumption 계획 대신, 컨테이너를 종료하고 확장하는 Basic B1 이상의 전용 계획을 사용하십시오. 지속적인 연결이 필요한 작업의 경우 Kubernetes 관리 컨테이너는 더 안정적인 옵션입니다.
2. gRPC 재시도 로직 설정
대상 프레임워크에 맞는 접근 방식을 선택하세요.
.NET Framework의 경우: JSON 재시도 정책과 함께 Grpc.Core.Channel를 사용하세요
using Grpc.Core;
using IronPdf.GrpcLayer;
string jsonString = @"
{
""methodConfig"": [
{
""name"": [
{
""service"": ""ironpdfengineproto.IronPdfService""
}
],
""retryPolicy"": {
""maxAttempts"": 5,
""initialBackoff"": ""1.0s"",
""maxBackoff"": ""30s"",
""backoffMultiplier"": 1.5,
""retryableStatusCodes"": [
""UNAVAILABLE""
]
}
}
]
}";
var channel = new Channel("localhost:33350", ChannelCredentials.Insecure,
new[]
{
new ChannelOption("grpc.service_config", jsonString)
});
IronPdf.Installation.ConnectToIronPdfHost(
IronPdfConnectionConfiguration.WithCustomChannel(channel)
);
using Grpc.Core;
using IronPdf.GrpcLayer;
string jsonString = @"
{
""methodConfig"": [
{
""name"": [
{
""service"": ""ironpdfengineproto.IronPdfService""
}
],
""retryPolicy"": {
""maxAttempts"": 5,
""initialBackoff"": ""1.0s"",
""maxBackoff"": ""30s"",
""backoffMultiplier"": 1.5,
""retryableStatusCodes"": [
""UNAVAILABLE""
]
}
}
]
}";
var channel = new Channel("localhost:33350", ChannelCredentials.Insecure,
new[]
{
new ChannelOption("grpc.service_config", jsonString)
});
IronPdf.Installation.ConnectToIronPdfHost(
IronPdfConnectionConfiguration.WithCustomChannel(channel)
);
Imports Grpc.Core
Imports IronPdf.GrpcLayer
Dim jsonString As String = "
{
""methodConfig"": [
{
""name"": [
{
""service"": ""ironpdfengineproto.IronPdfService""
}
],
""retryPolicy"": {
""maxAttempts"": 5,
""initialBackoff"": ""1.0s"",
""maxBackoff"": ""30s"",
""backoffMultiplier"": 1.5,
""retryableStatusCodes"": [
""UNAVAILABLE""
]
}
}
]
}"
Dim channel = New Channel("localhost:33350", ChannelCredentials.Insecure,
{
New ChannelOption("grpc.service_config", jsonString)
})
IronPdf.Installation.ConnectToIronPdfHost(
IronPdfConnectionConfiguration.WithCustomChannel(channel)
)
.NET Core / .NET 5+의 경우: Grpc.Net.Client.GrpcChannel와 RetryPolicy를 사용하세요
using Grpc.Net.Client;
using Grpc.Net.Client.Configuration;
using IronPdf.GrpcLayer;
using Grpc.Core;
var retryPolicy = new RetryPolicy
{
MaxAttempts = 5,
InitialBackoff = TimeSpan.FromSeconds(1),
MaxBackoff = TimeSpan.FromSeconds(30),
BackoffMultiplier = 1.5,
RetryableStatusCodes = { StatusCode.Unavailable }
};
var methodConfig = new MethodConfig
{
Names = { MethodName.Default },
RetryPolicy = retryPolicy
};
var channel = GrpcChannel.ForAddress("http://localhost:33350", new GrpcChannelOptions
{
ServiceConfig = new ServiceConfig { MethodConfigs = { methodConfig } }
});
IronPdf.Installation.ConnectToIronPdfHost(
IronPdfConnectionConfiguration.WithCustomChannel(channel)
);
using Grpc.Net.Client;
using Grpc.Net.Client.Configuration;
using IronPdf.GrpcLayer;
using Grpc.Core;
var retryPolicy = new RetryPolicy
{
MaxAttempts = 5,
InitialBackoff = TimeSpan.FromSeconds(1),
MaxBackoff = TimeSpan.FromSeconds(30),
BackoffMultiplier = 1.5,
RetryableStatusCodes = { StatusCode.Unavailable }
};
var methodConfig = new MethodConfig
{
Names = { MethodName.Default },
RetryPolicy = retryPolicy
};
var channel = GrpcChannel.ForAddress("http://localhost:33350", new GrpcChannelOptions
{
ServiceConfig = new ServiceConfig { MethodConfigs = { methodConfig } }
});
IronPdf.Installation.ConnectToIronPdfHost(
IronPdfConnectionConfiguration.WithCustomChannel(channel)
);
Imports Grpc.Net.Client
Imports Grpc.Net.Client.Configuration
Imports IronPdf.GrpcLayer
Imports Grpc.Core
Dim retryPolicy As New RetryPolicy With {
.MaxAttempts = 5,
.InitialBackoff = TimeSpan.FromSeconds(1),
.MaxBackoff = TimeSpan.FromSeconds(30),
.BackoffMultiplier = 1.5,
.RetryableStatusCodes = {StatusCode.Unavailable}
}
Dim methodConfig As New MethodConfig With {
.Names = {MethodName.Default},
.RetryPolicy = retryPolicy
}
Dim channel As GrpcChannel = GrpcChannel.ForAddress("http://localhost:33350", New GrpcChannelOptions With {
.ServiceConfig = New ServiceConfig With {.MethodConfigs = {methodConfig}}
})
IronPdf.Installation.ConnectToIronPdfHost(
IronPdfConnectionConfiguration.WithCustomChannel(channel)
)
3. RemoteServer 사용하여 간단한 설정
사용자 지정 채널 옵션이 필요하지 않은 경우, RemoteServer는 내장된 재시도 지원을 제공하며 대부분의 Azure 컨테이너 배포에 추천 시작점입니다. 엔진과 애플리케이션 컨테이너가 동일한 로컬 네트워크에 있지 않을 때 .Docker() 대신 이것을 사용하십시오. 전체 연결 설정 참고사항은 IronPDF Engine 가이드를 참조하십시오.
IronPdf.Installation.ConnectToIronPdfHost(
IronPdfConnectionConfiguration.RemoteServer("http://your-container-host:33350")
);
IronPdf.Installation.ConnectToIronPdfHost(
IronPdfConnectionConfiguration.RemoteServer("http://your-container-host:33350")
);
Imports IronPdf
IronPdf.Installation.ConnectToIronPdfHost( _
IronPdfConnectionConfiguration.RemoteServer("http://your-container-host:33350") _
)
4. 요청 간 엔진 종료 방지
기본적으로 IronPDF는 요청 간에 엔진을 종료합니다. SkipShutdown를 true로 설정하면 엔진 프로세스가 살아남아 있어 다시 연결하는 데 드는 비용을 줄이고 장시간 실행되는 컨테이너의 연결 오류 가능성을 줄입니다.
IronPdf.Installation.SkipShutdown = true;
IronPdf.Installation.SkipShutdown = true;
IronPdf.Installation.SkipShutdown = True
디버그 팁
상세한 gRPC 진단 출력을 얻으려면, Dockerfile 또는 컨테이너 설정에 다음 환경 변수를 설정하세요:
ENV GRPC_TRACE=all
ENV GRPC_VERBOSITY=DEBUG
연결 실패에 대한 추가 세부정보는 cef.log 및 IronSoftware.log를 확인하세요. Azure에서 로그 파일을 가져오는 방법에 대해 학습하려면 Azure Log Files를 참조하세요.

