2017-02-09 1 views
0

면책 조항 작동하지 : HTTP : this question 유사를,이 사람은 대부분 내가 HTTP 서비스를 생성하기 위해 ServiceHost를 개체를 사용하는 answer윈도우 netsh를 "+"와일드 카드는 ServiceHost를 위해

에서 의견을 투표에 특정 : // {IP} : 80/myService

내 애플리케이션은 관리자가 아닌 계정에서 실행됩니다 (이 경우에는 이와 같이 유지해야합니다). 여러 소스에서 나는 솔루션 프롬프트 cmd를 관리자에서 다음을 호출하는 것을 발견 :이 작동하지 않습니다

netsh http add urlacl url=http://+:80/myService/ user=Everyone

, 난 여전히 액세스에 관한 예외가 얻을 : 그러나

System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http://127.0.0.1:80/myService/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). ---> System.Net.HttpListenerException: Access is denied 
    at System.Net.HttpListener.AddAllPrefixes() 
    at System.Net.HttpListener.Start() 
    at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() 
    --- End of inner exception stack trace --- 
    at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() 
    at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener) 
    at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback) 
    at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout) 
    at System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 
    at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 
    at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Open() 

경우를 I 이 줄을 호출, 그것을 작동 :

netsh http add urlacl url=http://127.0.0.1:80/myService/ user=Everyone

주 I 명시 적으로 지정된 t 그는 IP 다. 사용자가 사용할 IP를 모르므로 작동하려면 + 와일드 카드가 필요합니다. 왜 작동하지 않는 지 알 수 없으며 이에 대한 해결 방법을 찾을 수 없습니다.

  • 관리자 권한으로 실행은 해결책이 아닙니다. 나뿐만 아니라이 정확한 시나리오가 발생했습니다
+0

명령 끝에 'listen = yes'를 추가하면 아무 것도 변경되지 않습니까? –

+0

listen = yes가 기본값이며, 또한 delegate = yes로 시도했지만 효과가 없습니다. –

답변

1

  • 찾을 Microsoft의 UrlPrefix 와일드 카드에 대한 정보하지만 여전히 명확하지 않다. 지금까지는 Windows의 버전에 따라 동작이 실제로 달라지는 것으로 생각됩니다. Windows 10은 루프백 IP (127.0.0.1)의 URL 예약을 다르게 처리하는 것처럼 보입니다 - 다른 모든 것은 예상대로 작동하는 것 같습니다.

    내 Windows 10 컴퓨터에서는 강력한 와일드 카드 (예 : http://+:80/)로 예약 한 경우 로컬 루프백에 연결된 URL 접두사를 등록 할 때마다 실패합니다. 그러나 이 아니며 Windows Server 2008 또는 2012의 경우는입니다. 거기에서 잘 작동합니다.

    나는 이것과 관련이 있다고 확신하지만, 사실은 해당 사용자의 해당 포트에서 (그리고 관리자가 아닌) 사전 예약 없이는 Windows 10에서 로컬 루프백에 URL을 성공적으로 등록했습니다. 이상한 점은 이것이 가능하다는 것을 나타내는 어떤 문서도 찾을 수 없다는 것입니다. 다음은 netsh http show servicestate에 대한 호출의 출력이되는 하나 명의 예약 : 이상한 접두사 형식 (HTTP://127.0.0.1:8081:127.0.0.1/)이 있음을

    Server session ID: E700000120000035 
    Version: 2.0 
    State: Active 
    Properties: 
        Max bandwidth: 4294967295 
        Timeouts: 
         Entity body timeout (secs): 120 
         Drain entity body timeout (secs): 120 
         Request queue timeout (secs): 120 
         Idle connection timeout (secs): 120 
         Header wait timeout (secs): 120 
         Minimum send rate (bytes/sec): 150 
    URL groups: 
    URL group ID: DF00000140000004 
        State: Active 
        Request queue name: Request queue is unnamed. 
        Properties: 
         Max bandwidth: inherited 
         Max connections: inherited 
         Timeouts: 
          Timeout values inherited 
         Number of registered URLs: 1 
         Registered URLs: 
          HTTP://127.0.0.1:8081:127.0.0.1/ 
    

    주 - 그게 내가 (그냥 http://127.0.0.1:8081 지정) ServiceHost를 전달 것이 아니다. Microsoft는 어느 시점에 netsh을 통해 사전 예약없이 로컬 루프백에서 '특별'URL 등록을 할 수있는 기능을 도입 한 것으로 의심합니다.

    이것은 내 생각에 순수한 추측이지만이 특별한 예약에는 보안상의 이유로 로컬 루프백에만 바인딩하는주의 사항도 포함되어 있다고 생각됩니다. http.sys의 기본 소켓은 로컬 루프백에만 바인딩됩니다. 이것은 다른 포트에서 들어오는 원격 요청을 포함 할 수있는 http://+:80/ 예약에 해당하는 포트에서 요청을 처리하려는 다른 프로세스와 분명히 충돌합니다.

  • 관련 문제