zoukankan      html  css  js  c++  java
  • An existing connection was forcibly closed by the remote host

     

    Server Error in '/InsusTutorials' Application.

    An existing connection was forcibly closed by the remote host

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

    Source Error:

    Line 48:         
    Line 49:         public System.Data.DataTable GetGlobalAddressList() {
    Line 50:             return base.Channel.GetGlobalAddressList();
    Line 51:         }
    Line 52:     }

    Source File: c:\Users\xxxxx\AppData\Local\Temp\Temporary ASP.NET Files\insustutorials\3791b6cb\f7905baa\App_WebReferences.wnen5_ok.0.cs Line: 50

    Stack Trace:

    [SocketException (0x2746): An existing connection was forcibly closed by the remote host]
       System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +6157192
       System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +134
    
    [IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
       System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +300
       System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) +26
       System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) +265
    
    [WebException: The underlying connection was closed: An unexpected error occurred on a receive.]
       System.Net.HttpWebRequest.GetResponse() +6063239
       System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +48
    
    [CommunicationException: An error occurred while receiving the HTTP response to http://xxx.xxx.com/InsusServices/GAL.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.]
       System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9464975
       System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345
       GAL.IGAL.GetGlobalAddressList() +0
       GAL.GALClient.GetGlobalAddressList() in c:\Users\xxxx\AppData\Local\Temp\Temporary ASP.NET Files\insustutorials\3791b6cb\f7905baa\App_WebReferences.wnen5_ok.0.cs:50
       _Default.Page_Load(Object sender, EventArgs e) in d:\Projects\InsusTutorials\Default.aspx.cs:22
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +91
       System.Web.UI.Control.LoadRecursive() +74
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
    



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.431

    你可以看到此篇,http://www.cnblogs.com/insus/archive/2011/08/30/2159776.html 这个Service返回的是string[]数据类型,今天Insus.NET尝试再次修改它,因为需要邮件的昵称与邮件地址,因此,把它改为返回一个DataTable,编译发布之后,程序去读取这个Services时,就出现上面这个错误。

    WCF参考文章与网上很多网友的说法, WCF不能返回一个DataTable数据类型。

    不过,Insus.NET的解决方法,很简单,只是添加一句:

    dataTable.TableName = "GAL"//添加此句,给这个DataTable一个表名。 

    Service.svc全部代码:

    GetGlobalAddressList
    public DataTable GetGlobalAddressList()
        {
            DirectorySearcher objsearch 
    = new DirectorySearcher();
            
    string strrootdse = objsearch.SearchRoot.Path;
            DirectoryEntry objdirentry 
    = new DirectoryEntry(strrootdse);

            objsearch.Filter 
    = "(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*))) ))";

            objsearch.SearchScope 
    = System.DirectoryServices.SearchScope.Subtree;
            objsearch.PropertiesToLoad.Add(
    "cn");
            objsearch.PropertiesToLoad.Add(
    "Mail");
            objsearch.PropertyNamesOnly 
    = true;
            objsearch.Sort.Direction 
    = System.DirectoryServices.SortDirection.Ascending;
            objsearch.Sort.PropertyName 
    = "cn";
            objsearch.Sort.PropertyName 
    = "Mail";
            SearchResultCollection colresults 
    = objsearch.FindAll();

            DataTable dataTable 
    = new DataTable();
            dataTable.TableName 
    = "GAL"//添加此句,给这个DataTable一个表名。
            DataRow dataRow;

            dataTable.Columns.Add(
    new DataColumn("nickname"typeof(string)));
            dataTable.Columns.Add(
    new DataColumn("mail"typeof(string)));

            
    foreach (SearchResult objresult in colresults)
            {
                dataRow 
    = dataTable.NewRow();
                dataRow[
    "nickname"= objresult.GetDirectoryEntry().Properties["cn"].Value;
                dataRow[
    "mail"= objresult.GetDirectoryEntry().Properties["Mail"].Value;
                dataTable.Rows.Add(dataRow);
            }
            objsearch.Dispose();
            
    return dataTable;
        }

  • 相关阅读:
    会话跟踪之Session
    利用Cookie保存用户身份信息实现免登录
    会话跟踪之Cookie
    JSP的使用
    Servlet的生命周期以及线程安全问题
    将数组转化成递归
    自己配置webpack的vue
    自己配置webpack打包
    echarts堆叠图tooltip中如何仅展示鼠标当前位置相应的指标数据
    富文本编辑器的毛毛雨
  • 原文地址:https://www.cnblogs.com/insus/p/2160493.html
Copyright © 2011-2022 走看看