none
WCF Windows Service Using NetTCPbinding RRS feed

  • Question

  • Hi ,

    I have developed WCF windows service using net tcp binding which is hosted inwindows (wcf service hosted in windows). Its working fine when wcf client and wcf service both are in domain (in two different system)

    Getting error when both system are in work group not in domain

    please suggest what configuration i need to change .

    Error :System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:29:59.9687496'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

    Thanks

    Sanjay


    • Moved by Sabah ShariqMVP Tuesday, February 28, 2017 11:59 AM Moved From Visual C#
    • Edited by sanjaytdc Tuesday, February 28, 2017 12:24 PM
    Tuesday, February 28, 2017 11:56 AM

Answers

  • Hi,

    Do you need Transport with Windows Security? If you do, it is impossible.

    If not, I suggest you try to removing the security mode="Transport", update client service reference, and try again.

    Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by sanjaytdc Friday, March 3, 2017 9:40 AM
    Friday, March 3, 2017 3:05 AM

All replies

  • Hi sanjaytdc,

    This is Visual C# forum. As your issue is related to WCF I am moving your thread to WCF forum for getting quick response.

    Your understanding and cooperation will be grateful.

    Thanks,
    Sabah Shariq

    [If a post helps to resolve your issue, please click the "Mark as Answer" of that post or click Answered "Vote as helpful" button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]

    Tuesday, February 28, 2017 11:59 AM
  • thanks for moving to correct thread
    Tuesday, February 28, 2017 12:10 PM
  • If you are using Windows Authentication, NetTcpbinding will not work between domains that do not trust one another.

    You have atleast 2 choices:

    • username and password in message header
    • a pre-installed certificate

    william xifaras


    Tuesday, February 28, 2017 7:18 PM
  • Hi Sanjay,

    In addition to the suggestion from William, I suggest you check whether the systems could Ping from one to another.

    If you are not using Windows Authentication, it would be helpful if you could share us your configuration file of WCF Service.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 1, 2017 2:44 AM
  • Below configuration working finewhen both systems are in domain but not working when both system client and service is in no domain (workgroup)

    <system.serviceModel>
        <bindings>
          <netTcpBinding>
            <binding name="WCFServiceHostNetTcpEndPoint" receiveTimeout="00:15:00" sendTimeout="00:15:00"  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" portSharingEnabled="true" >
              <readerQuotas maxStringContentLength="2147483647" maxDepth="2147483647" maxArrayLength="2147483647" maxNameTableCharCount="2147483647"/>
              <security mode="Transport">
                <transport clientCredentialType="Windows" protectionLevel="None" />
                <message clientCredentialType="Windows" />
              </security>
            </binding>
          </netTcpBinding>
        </bindings>
        
        <behaviors>
          <serviceBehaviors>
            <behavior name="TnTWindows_Services.WCFServiceHostBehaviour">
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceMetadata />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <services>
          <service behaviorConfiguration="TnTWindows_Services.WCFServiceHostBehaviour" name="TnTWindows_Services.ClientWinServices">
           
           <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
              name="WCFServiceHostNetTcpEndPoint" contract="TnTWindows_Services.IClientWinServices" />        
            
            <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
              name="WCFServiceHostMexTcpEndPoint" contract="IMetadataExchange" />
            <host>
              <baseAddresses>           
                <add baseAddress="net.tcp://localhost:8080/ClientWinServices" />
                
              </baseAddresses>
            </host>
          </service>
        </services>
      </system.serviceModel>

    Please advice on how to run WCF windows service using NetTCPBinding in workgroup

    Thanks

    Sanjay


    • Edited by sanjaytdc Wednesday, March 1, 2017 6:24 AM
    Wednesday, March 1, 2017 5:47 AM
  • Dear Edward,

    system is pinging from another system also i have shared clients and service config file as below.

    -----------Client-----------

    <system.serviceModel>
        <bindings>
          <netTcpBinding>
            <binding name="TcpBinding1" receiveTimeout="00:15:00" sendTimeout="00:15:00"
              transactionFlow="false" listenBacklog="2147483647" maxBufferPoolSize="2147483647"
              maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
              portSharingEnabled="false">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxNameTableCharCount="2147483647" />
              <security mode="None">
                <transport clientCredentialType="None" protectionLevel="None" />
                <message clientCredentialType="None" />
              </security>
            </binding>
          
            
          </netTcpBinding>
        </bindings>
        <client>
          <endpoint address="net.tcp://localhost:8080/ClientWinServices"
            binding="netTcpBinding" bindingConfiguration="TcpBinding1" contract="ClientService.IClientWinServices"
            name="TcpBinding1">
            <identity>
              <servicePrincipalName value="host/ACGIDT025.ACGI.COM" />
            </identity>
          </endpoint>
          
          
        </client>
      </system.serviceModel>

    ----------Service config----------

    <system.serviceModel>
        <bindings>
          <netTcpBinding>
            <binding name="WCFServiceHostNetTcpEndPoint" receiveTimeout="00:15:00" sendTimeout="00:15:00"  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" portSharingEnabled="true" >
              <readerQuotas maxStringContentLength="2147483647" maxDepth="2147483647" maxArrayLength="2147483647" maxNameTableCharCount="2147483647"/>
              <security mode="Transport">
                <transport clientCredentialType="Windows" protectionLevel="None" />
                <message clientCredentialType="Windows" />
              </security>
            </binding>
          </netTcpBinding>
        </bindings>
        
        <behaviors>
          <serviceBehaviors>
            <behavior name="TnTWindows_Services.WCFServiceHostBehaviour">
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceMetadata />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <services>
          <service behaviorConfiguration="TnTWindows_Services.WCFServiceHostBehaviour" name="TnTWindows_Services.ClientWinServices">
           
           <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
              name="WCFServiceHostNetTcpEndPoint" contract="TnTWindows_Services.IClientWinServices" />        
            
            <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
              name="WCFServiceHostMexTcpEndPoint" contract="IMetadataExchange" />
            <host>
              <baseAddresses>           
                <add baseAddress="net.tcp://localhost:8080/ClientWinServices" />
                
              </baseAddresses>
            </host>
          </service>
        </services>
      </system.serviceModel>

    wcf  service using net tcpbinding hosted in windows should work without domain above configuration working fine when both system are in domain

    Thanks

    Sanjay

    • Edited by sanjaytdc Wednesday, March 1, 2017 6:23 AM
    Wednesday, March 1, 2017 6:22 AM
  • Hi Sanjay,

    I am confused that your service could work under domain. Transport security with Windows in service side, and None security at client side.

    >> wcf  service using net tcpbinding hosted in windows should work without domain above configuration working fine when both system are in domain

    Windows Authentication should be used in domains. It would not work in workgroup.

    Windows Communication Foundation (WCF) service that resides in a Windows domain and is called by clients in the same domain.

    # How to: Secure a Service with Windows Credentials

    https://msdn.microsoft.com/en-us/library/ms734673(v=vs.110).aspx

    For Windows security in workaroup, you need to ensure that local user account exists on the service machine.

    # Running the Samples in a Workgroup and Across Machines

    https://msdn.microsoft.com/en-us/library/ms751525(v=vs.90).aspx

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 1, 2017 7:48 AM
  •  

    Edward I have clearly mentioned that given configuration working fine in domian.

    Note: I want wcf service (windows hosted) using net tcp binding should work without domain so what changes do i need  in configuration.

    I have WCFservice using nettcpbinding and client both should work in none domain scenario so where and what i have to change  

    Thanks

    Sanjay


    • Edited by sanjaytdc Wednesday, March 1, 2017 11:06 AM
    Wednesday, March 1, 2017 10:56 AM
  • Dear Edward,

    When i call one wcf service from another wcf service in non domain environment then its throwing error.

    System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9920000'. ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9920000'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
       at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
       at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
       --- End of inner exception stack trace ---
       at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
       at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
       at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
       at System.Net.Security.NegotiateStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       --- End of inner exception stack trace ---
       at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
       at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)


    Thanks

    Sanjay


    • Edited by sanjaytdc Friday, March 3, 2017 12:28 PM
    Thursday, March 2, 2017 6:53 AM
  • Hi,

    Do you need Transport with Windows Security? If you do, it is impossible.

    If not, I suggest you try to removing the security mode="Transport", update client service reference, and try again.

    Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by sanjaytdc Friday, March 3, 2017 9:40 AM
    Friday, March 3, 2017 3:05 AM
  • Thanks for suggestion

    Now my Service is working in non domain

    I have second scenario where same WCF service i am using as server WCF service using chanel factory dynamic binding. Here i have one console app and WCF service on same machine then same wcf service is hosted on another wcf service using nettcpbinding. When console app sends RQ to local WCF service then local wcf service call server wcf service using channel factory.

    above scenario working fine when both system are in domain .

    But not working in non domain scenario .Can u please suggest how to fix this issues.

    Error :System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9920000'. ---> System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9920000'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
       at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
       at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
       --- End of inner exception stack trace ---
       at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
       at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
       at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
       at System.Net.Security.NegotiateStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       --- End of inner exception stack trace ---
       at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
       at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       --- End of inner exception stack trace ---

    Server stack trace:
       at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
       at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at TnTWindows_Services.IClientWinServices.InsertProductionDetails(ProductionDetails productionDetails)
       at TnTWindows_Services.ClientWinServices.InsertProductionDetails(ProductionDetails productionDetails) in E:\MS_Technology\trunk\NewTnTClient\TnTClientWinService\TnTWindows_Services\ClientWinServices.cs:line 457MessageThe socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9920000'.Trace
    Server stack trace:
       at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
       at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
       at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at TnTWindows_Services.IClientWinServices.InsertProductionDetails(ProductionDetails productionDetails)
       at TnTWindows_Services.ClientWinServices.InsertProductionDetails(ProductionDetails productionDetails) in E:\MS_Technology\trunk\NewTnTClient\TnTClientWinService\TnTWindows_Services\ClientWinServices.cs:line 457

    Thanks

    Sanjay

    Friday, March 3, 2017 9:47 AM
  • Hi,

    For this new issue, I would suggest you post a new thread, and then we could focus on this specific issue.

    In the new thread, I would suggest you share us the code how you configure WCF Service.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 6, 2017 5:40 AM