【发布时间】:2021-09-29 02:47:49
【问题描述】:
我在我的服务器中部署了一项服务,这是使用 WCF 服务的自托管应用程序。 我的应用程序充当数据库和前端应用程序之间的桥梁,两个应用程序都是 WPF。 它多年来一直运行良好,我一直在升级“桥接”应用程序和前端应用程序,除了连接问题之外没有任何问题。
目前我正在使用 HTTP 基本绑定在它们之间进行通信,没有问题,但是前段时间我使用 TCP,因为它更快并且它突然停止工作,找不到真正的原因,所以我只是切换到 HTTP,之后所有这个协议都不需要我偶尔 ping 来保持连接,即使它更慢但更方便。
最近几天前,我无法再在应用程序之间进行通信,互联网通信不再起作用,它发送“无 HTTP 响应”错误,但我的 Intranet 连接没有问题,我仍然可以在没有任何问题的情况下进行问题,它只是失败时的互联网连接。
-
我最近没有更新这两个应用程序。
-
代码在 Intranet 中运行良好
这让我相信我确实做得对,因此我进行了一系列测试以找出问题所在,但都没有结果:
-
禁用防火墙
-
我有几个备份,我使用了一些以前的实例,仍然无法正常工作
-
停止其他服务
-
更改了配置文件中的一些配置参数
-
我尝试制作一个示例服务以在服务器中托管它,但最新的 VS2019 不包含 system.servicemodel DLL 参考(微软修复你的废话),而不是试图修复这个我只是向前修复我当前的问题
-
更改的端口
-
多次重启服务器。
-
多次重启这两个应用程序。
这是踪迹:
服务器堆栈跟踪: zh System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) zh System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) en System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) en System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) en System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) zh System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime 操作) zh System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)
在 [0] 处重新抛出异常: zh System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) zh System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 类型) zh IConexion.Ping() zh ConexionClient.Ping()
内部异常: Se ha terminado la conexión: Error inesperado de recepción。 zh System.Net.HttpWebRequest.GetResponse() en System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
内部异常: No se puede escribir datos de en la conexión de transporte: Se ha forzado la interrupción de una conexiónexistente por el host remoto。 en System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) zh System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) en System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
内部异常: Se ha forzado la interrupción de una conexión existente por el host remoto en System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) en System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
我正在使用 WCFtestClient,有时它会添加服务,有时它不会:当它获取所有元数据但没有任何作用时,发送该跟踪,我什至有一些方法(PING() 什么都不返回,它用于保持连接活动,而另一个返回一年中的月份的连接也不起作用。
我有一些网站托管在服务器上,可以毫无问题地从 Intranet 和 Internet 访问,这些网站使用这个“桥梁”从数据库中检索数据,因此它在本地也可以正常工作。
我还使用了跟踪日志:无法发布所有代码,但显示 I/O 应用程序错误
谁能帮我弄清楚到底发生了什么?现在,我打算用我的 PC 来托管它并从另一台计算机访问,可能是服务器出了问题(我没有 UPS,最近由于下雨有一些电流中断),也许它得到了以某种方式损坏,但我最后的手段是重新安装 Windows 服务器。 谢谢!
编辑:我在不同的机器上运行实例,同样的问题......我不知道发生了什么。
编辑 2:这是配置文件代码:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<services>
<service name="BSUITE_CONSOLA.Conexion">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
contract="BSUITE_CONSOLA.IConexion" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:80/BDB/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
<useRequestHeadersForMetadataAddress />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="tcp_Unsecured" >
<reliableSession enabled="true" />
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
编辑 3:我知道使用套接字更难编程,但你认为它的故障更少吗?我厌倦了 WCF 随机失败
编辑 4:我尝试在不同的计算机上托管,使用不同的端口,使用不同的协议(TCP、NETTCP、NETHTPS)。目前我使用 Visual Studio 托管应用程序并使用另一个网络上的 WCFtestclient 进行调试以进行连接,它只获取元数据,但在调用时无法检索任何方法
【问题讨论】: