C# 콘솔 앱을 Azure로 마이그레이션합니다. 내 응용 프로그램은 HttpListener
을 사용하여 특정 포트에서 http 요청을 수신 대기합니다. - "프로세스가 파일을 액세스 할 수 없습니다가 사용 중이기 때문에청취 시작시 작업자 역할의 HttpListenerException
HttpListenerException : 나는 작업자 역할에 로컬로 다음과 같은 테스트 코드를 시도 할 때, 나는 말을합니다 (ComputeEmulator 화면에서 유사한 프린트) 예외를 얻었다 다른 프로세스 "라고합니다.
참고 : 서비스 구성 파일에서 포트를 2020으로 구성했습니다. 또한 RoleEnvironment에서 가져온 포트가 2020이라는 것을 알았지 만 구성된 외부 포트 번호와 다른 포트로 다시 매핑해야하기 때문에 다른 포트를 표시한다고 가정합니까?
// ========== Test code starts ==============
string ipAddress = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Ecard"].IPEndpoint.Address.ToString();
int port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Ecard"].IPEndpoint.Port;
string uri = @"http://" + ipAddress + ":" + port + "/";
try
{
httpListener = new HttpListener();
httpListener.Prefixes.Add(uri);
httpListener.Start();
}
catch (Exception e)
{
Trace.WriteLine(e.Message);
}
// Test code ends.
정말 감사드립니다.