none
使用remoting的时候. 出现了 基础连接已经关闭: 无法连接到远程服务器。由于系统缓冲区空间不足或列队已满,不能执行套接字上的操作 RRS feed

  • 问题

  • '获取远程对象 Private Function getHlDelegate() As IHLClientRegiste Return DirectCast(Activator.GetObject(GetType(IHLClientRegiste), ServerIp & "/tpclient"), IHLClientRegiste) End Function '向服务器发送心跳-间隔25s Public Sub RegistServerClientEvent(ByVal act As Action(Of Com.IComm.message)) Dim dlg As IHLClientRegiste = getHlDelegate() Dim bt As New clsbetweenEvent dlg.dlgAdd(SoftKey, New ihldelegate(Of Com.IComm.message)(AddressOf bt.hlDispatchMsg)) bt.dlgmsg = New ihldelegate(Of Com.IComm.message)(Sub(st As Com.IComm.message) act(st) End Sub) End Sub

      Private Sub tm_CallBack(ByVal sender As Object, ByVal e As Timers.ElapsedEventArgs)

      If (Not IsNothing(hlremote)) Then
                    If (Not hlremote.ClientHeartbeat()) Then
                        hlremote.RegistServerClientEvent(New Action(Of message)(AddressOf CallBack))
                    End If
                End If

    End Sub

    客户端注册代码:

        Public Sub RegisterNotityService()
            Dim serverProvider As New BinaryServerFormatterSinkProvider()
            Dim clientProvider As New BinaryClientFormatterSinkProvider()
            serverProvider.TypeFilterLevel = TypeFilterLevel.Full
            Dim props As IDictionary = New Hashtable()
            props("port") = 0
            props("bindTo") = localIp
            Dim Tcp As TcpChannel = New TcpChannel(props, clientProvider, serverProvider)
            Dim pp As System.Runtime.Remoting.Channels.ChannelDataStore = Tcp.ChannelData
            For Each p In pp.ChannelUris
                Com.IComm.comUtil.PrintErrorHandle("客户端注册Ip: " & p)
            Next
            ChannelServices.RegisterChannel(Tcp, False)
        End Sub

    服务端实例代码:

        Private Sub RemotingHLMsg()
            Dim tpclient As Com.IComm.IHLClientRegiste = Com.Library.PushList.GetIntance()
            RemotingServices.Marshal(tpclient, "tpclient")
            Com.IComm.comUtil.PrintErrorHandle("托盘服务注册成功")
        End Sub

    大概1-2天内就会出现异常:客户端先出现异常

    2014-06-08 12:39:44    4     tm_CallBack : 由于系统缓冲区空间不足或列队已满,不能执行套接字上的操作。 127.0.0.1:8642
    Server stack trace: 
       在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       在 System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
       在 System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket(EndPoint ipEndPoint)
       在 System.Runtime.Remoting.Channels.RemoteConnection.CreateNewSocket()
       在 System.Runtime.Remoting.Channels.RemoteConnection.GetSocket()
       在 System.Runtime.Remoting.Channels.SocketCache.GetSocket(String machinePortAndSid, Boolean openNew)
       在 System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.SendRequestWithRetry(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream)
       在 System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
       在 System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
    
    Exception rethrown at [0]: 
       在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       在 Com.IComm.IHLClientRegiste.ClientHeartbeat(String softkey)
       在 HLCost168Notity.ClsRemoting.ClientHeartbeat() 位置 D:\Code\HLWindowsService_VB\HLWindowsService_VB\HLServiceNotity\HLRemoting\ClsRemoting.vb:行号 49
       在 HLCost168Notity.Form1.tm_CallBack(Object sender, ElapsedEventArgs e) 位置 D:\Code\HLWindowsService_VB\HLWindowsService_VB\HLServiceNotity\Form1.vb:行号 177


    接着服务端也出现异常:

    2014-06-08 12:59:36    57     ClientRegister_ClientRegister : 基础连接已经关闭: 无法连接到远程服务器。由于系统缓冲区空间不足或列队已满,不能执行套接字上的操作。   在 System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
       在 System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
       在 System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
       在 System.Net.Connection.CompleteStartConnection(Boolean async, HttpWebRequest httpWebRequest)在 Com.Library.HttpHelp.GetString(String url, Encoding _encoding, String ContentType, Int32 timeout) 位置 D:\Code\HLWindowsService_VB\HLWindowsService_VB\Com168.Library\HttpHelp.vb:行号 29
       在 Com.Library.clsHeartBeat.ClientRegister(String hosturl) 位置 D:\Code\HLWindowsService_VB\HLWindowsService_VB\Com168.Library\clsHeartBeat.vb:行号 43
    

    异常时打印tcp 端口

    Active Connections
    
      Proto  Local Address          Foreign Address        State           PID
      TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       584
      TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       1208
      TCP    0.0.0.0:443            0.0.0.0:0              LISTENING       584
      TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
      TCP    0.0.0.0:1098           0.0.0.0:0              LISTENING       584
      TCP    0.0.0.0:1433           0.0.0.0:0              LISTENING       1592
      TCP    0.0.0.0:4570           0.0.0.0:0              LISTENING       552
      TCP    0.0.0.0:10002          0.0.0.0:0              LISTENING       1116
      TCP    127.0.0.1:1304         127.0.0.1:1305         ESTABLISHED     4892
      TCP    127.0.0.1:1305         127.0.0.1:1304         ESTABLISHED     4892
      TCP    127.0.0.1:2602         0.0.0.0:0              LISTENING       5564
      TCP    127.0.0.1:8642         0.0.0.0:0              LISTENING       1540
      TCP    127.0.0.1:10466        127.0.0.1:16063        ESTABLISHED     8140
      TCP    127.0.0.1:16062        0.0.0.0:0              LISTENING       4748
      TCP    127.0.0.1:16063        0.0.0.0:0              LISTENING       4748
      TCP    127.0.0.1:16063        127.0.0.1:10466        ESTABLISHED     4748
      TCP    127.0.0.1:17175        127.0.0.1:17176        ESTABLISHED     4748
      TCP    127.0.0.1:17176        127.0.0.1:17175        ESTABLISHED     4748
      TCP    127.0.0.1:17182        127.0.0.1:17183        ESTABLISHED     4748
      TCP    127.0.0.1:17183        127.0.0.1:17182        ESTABLISHED     4748
      TCP    127.0.0.1:18980        127.0.0.1:8642         TIME_WAIT       0
      TCP    172.27.35.1:53         0.0.0.0:0              LISTENING       4892
      TCP    172.27.35.1:139        0.0.0.0:0              LISTENING       4
      TCP    172.27.35.1:8087       0.0.0.0:0              LISTENING       4892
      TCP    172.27.35.1:8171       0.0.0.0:0              LISTENING       4124
      TCP    172.27.35.1:8360       0.0.0.0:0              LISTENING       4124
      TCP    192.168.2.133:139      0.0.0.0:0              LISTENING       4
      TCP    192.168.2.133:17177    220.170.79.210:6064    ESTABLISHED     4748
      TCP    192.168.2.133:18971    125.171.0.76:80        ESTABLISHED     1540
      UDP    0.0.0.0:445            *:*                                    4
      UDP    0.0.0.0:1026           *:*                                    1160
      UDP    0.0.0.0:1177           *:*                                    2416
      UDP    0.0.0.0:1325           *:*                                    4892
      UDP    0.0.0.0:1434           *:*                                    1592
      UDP    0.0.0.0:3456           *:*                                    584
      UDP    0.0.0.0:13324          *:*                                    4748
      UDP    0.0.0.0:65435          *:*                                    3176
      UDP    127.0.0.1:123          *:*                                    1740
      UDP    127.0.0.1:1027         *:*                                    780
      UDP    127.0.0.1:1114         *:*                                    1740
      UDP    127.0.0.1:1140         *:*                                    724
      UDP    127.0.0.1:1275         *:*                                    3176
      UDP    127.0.0.1:1277         *:*                                    2324
      UDP    127.0.0.1:2605         *:*                                    5564
      UDP    172.27.35.1:53         *:*                                    4892
      UDP    172.27.35.1:67         *:*                                    4892
      UDP    172.27.35.1:123        *:*                                    1740
      UDP    172.27.35.1:137        *:*                                    4
      UDP    172.27.35.1:138        *:*                                    4
      UDP    172.27.35.1:8360       *:*                                    4124
      UDP    192.168.2.133:123      *:*                                    1740
      UDP    192.168.2.133:137      *:*                                    4
      UDP    192.168.2.133:138      *:*                                    4

    内存使用量:

    2014-06-08 12:39:43    4     HLCost168Notity:句柄数 564  pid: 5564  WorkingSet64:50663424  PeakWorkingSet64: 51081216  Threads: 14

    出现错误后系统蓝屏:错误日志:

    事件类型: 错误
    事件来源: Srv
    事件种类:
    事件 ID: 2019
    日期: 2014-6-8
    事件: 12:59:05
    用户: N/A
    计算机: XIEXY
    描述:
    服务器无法通过系统非页面共享区来进行分配,因为共享区当前是空的。

    有关更多信息,请参阅在 http://go.microsoft.com/fwlink/events.asp 的帮助和支持中心。
    数据:
    0000: 00 00 04 00 01 00 54 00   ......T.
    0008: 00 00 00 00 e3 07 00 c0   ....ã..À
    0010: 00 00 00 00 9a 00 00 c0   ....š..À
    0018: 00 00 00 00 00 00 00 00   ........
    0020: 00 00 00 00 00 00 00 00   ........
    0028: 03 00 00 00               ....    

    发现端口并没有使用完..那为什么会出现这种异常? 

    是否remoting每次发送心跳时,开启本地的tcp端口都不一样?导致tcp端口用完? 

    Thanks 

    祝工作顺利.


    • 已移动 Caillen 2014年6月10日 1:45
    2014年6月9日 2:03

全部回复