【问题标题】:WCF service not running on other devices except serverWCF 服务未在服务器以外的其他设备上运行
【发布时间】:2020-02-10 18:13:10
【问题描述】:

我有 WCF 服务,它使用 IP 在我的服务器机器上运行良好,它在客户端(android studio)上工作,但突然停止工作,我尝试了互联网上的所有解决方案,但似乎没有任何帮助,服务仍在工作服务器浏览器/邮递员。

如果需要,这是我的 web.config 文件:

<?xml version="1.0"?> 
<configuration>

<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.serviceModel>
<services>
  <service name="WcfService.Service1" behaviorConfiguration="WCFService.Service1Behavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="webHttpBinding" behaviorConfiguration="myWeb" contract="WcfService.IService1">
      <!-- 
          Upon deployment, the following identity element should be removed or replaced to reflect the 
          identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
          automatically.
      -->
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="myWeb">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="WCFService.Service1Behavior">
      <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
    <add binding="basicHttpBinding" scheme="http" />
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
    To browse web app root directory during debugging, set the value below to true.
    Set to false before deployment to avoid disclosing web app folder information.
  -->
 <directoryBrowse enabled="true"/>

 </system.webServer>

 </configuration>

我的防火墙也被完全禁用。 当我从手机或其他电脑 ping 服务时,它会出现错误: 无法访问此站点。 Err_Address_Unreachable

【问题讨论】:

  • 如果您说您无法访问它,“Service still.working on server”是什么意思?您尝试使用哪个设备?您尝试过哪个地址(本地主机)? “突然停止工作”是什么意思?
  • 仍在服务器上工作意味着如果我在服务器的浏览器或 Postman 上尝试它工作正常。我试图在浏览器和客户端应用程序上从另一台电脑和三星移动设备(顺便说一句,它之前正在使用)对其进行 ping 操作。地址:192.168.100.110:80/WcfService/Service1.svc/getColors 突然停止工作意味着它早些时候在移动/客户端/其他浏览器上运行良好,现在不是。我没有对服务器进行任何更改。
  • 检查防火墙是否在重新启动时重新启动,并检查您机器上的 antivir pgm
  • 防火墙已关闭,我一直在疯狂地检查它,因为所有答案都是如此建议的。我的机器上也没有安装防病毒程序。
  • ip 正确吗?也许 DHCP 给你分配了另一个?两台电脑必须在同一个局域网上,同时检查另一台电脑的IP。

标签: c# android-studio wcf service


【解决方案1】:

首先,您能否从同一局域网中的另一台计算机成功调用该服务?
二、你的移动设备的IP是多少?
最后,您是否尝试在当前 LAN 中重新启动路由器/交换机设备?有可能是提供寻址功能的路由器设备有问题。
如果有什么可以帮助的,请随时告诉我。

【讨论】:

  • 不,我现在不能,(它之前可以工作,但现在不行)。 IP已更改,但它连接在同一局域网上。是的,我已尝试重新启动路由器。
  • 这是第一个答案吗?如果确实如此,您可以从同一局域网中的另一台计算机成功 Ping 服务器吗?另外,如果IP发生变化,请使用最新的IP。
【解决方案2】:

如果您的计算机的防火墙被禁用,请检查您的路由器是否有防火墙并将其禁用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-04
    • 1970-01-01
    • 2017-05-12
    • 1970-01-01
    • 2019-07-07
    • 1970-01-01
    相关资源
    最近更新 更多