簡體   English   中英

無法從本地網絡外部連接到WCF服務

[英]Can`t connect to WCF service from outside of my local network

我正在學習編寫WCF服務,並通過閱讀的書中的示例逐步編寫了簡單的服務。 服務在我的PC以及連接到我的本地網絡的所有設備上均能正常運行。 當我嘗試從本地網絡的“外部”連接時,如果看不到服務(通過我編寫的客戶端應用程序和瀏覽器(MEX)),則無法訪問。

我的主機app.config:

    <system.serviceModel>

      <services>
       <service name="WCF_1_MagicEightBallService.MagicEightBallService"
                behaviorConfiguration="MagicEightBallServiceMEXBehavior">

         <endpoint address=""
                   binding="basicHttpBinding"
                   contract="WCF_1_MagicEightBallService.IMagicEightBall">
         </endpoint>

         <endpoint address="mex"
                   binding="mexHttpBinding"
                   contract="IMetadataExchange">
         </endpoint>

         <host>
           <baseAddresses>
             <add baseAddress="http://[my ip]:8080/MagicEightBallService"/>
           </baseAddresses>
         </host>

       </service>
      </services>

      <behaviors>
        <serviceBehaviors>
          <behavior name="MagicEightBallServiceMEXBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <useRequestHeadersForMetadataAddress/>
          </behavior>
        </serviceBehaviors>
      </behaviors>

  </system.serviceModel>

我的ip是我的外部ip,但是我嘗試使用帶和不帶wifi路由器以及不同端口的ip。

因此,正如Cameron在評論中提到的那樣,問題在於ISP阻止了我的端口。 這個答案可能與主題無關,但是對於每個有類似問題的人,我在這里做了以下工作:

  1. 使用基於控制台的免費實用程序“ nmap”使用以下命令掃描開放端口:
    nmap target.hostname.com
  2. 然后我通過http://www.yougetsignal.com/tools/open-ports/ (您當然可以使用任何其他網站)重新檢查了所有具有“未知”服務的端口。 它們都是打開的,並使用Windows命令:
    netstat -aon |查找/ i“正在偵聽” |查找“端口”
    我得到了正在使用它們的應用程序的PID。
  3. 我選擇了我不需要運行的應用程序使用的端口,將其關閉,並將該端口用於托管WCF服務的網站的IIS服務器綁定。

它起作用了,我可以通過我的外部IP地址進行遠程訪問。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM