none
using a host name in the Endpoint Address errors RRS feed

  • Question

  • Hi all,

    I've got a tcp self hosted wcf tcp service It seems that if i use a host name instead of an IP address in my uri, my process throws the followig error: A call to SSPI failed

    here is the stack trace:

    System.ServiceModel.Security.SecurityNegotiationException was caught
      HResult=-2146233087
      Message=A call to SSPI failed, see inner exception.
      Source=mscorlib
      StackTrace:
        Server stack trace:
           at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade(Stream stream, SecurityMessageProperty& remoteSecurity)
           at System.ServiceModel.Channels.StreamSecurityUpgradeInitiatorBase.InitiateUpgrade(Stream stream)
           at System.ServiceModel.Channels.ConnectionUpgradeHelper.InitiateUpgrade(StreamUpgradeInitiator upgradeInitiator, IConnection& connection, ClientFramingDecoder decoder, IDefaultCommunicationTimeouts defaultTimeouts, TimeoutHelper& timeoutHelper)
           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.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
           at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
           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 Contracts.IMsgService.Send(MessageEnvelope msg)
           at MsgClient.MsgClient.Send(DuplexChannelFactory`1 factory, MessageEnvelope env) in c:\Prototypes\MessagingServiceV1\MsgClient\MsgClient.cs:line 233
      InnerException: System.Security.Authentication.AuthenticationException
           HResult=-2146233087
           Message=A call to SSPI failed, see inner exception.
           Source=System
           StackTrace:
                at System.Net.Security.NegoState.StartSendAuthResetSignal(LazyAsyncResult lazyResult, Byte[] message, Exception exception)
                at System.Net.Security.NegoState.StartSendBlob(Byte[] message, LazyAsyncResult lazyResult)
                at System.Net.Security.NegoState.CheckCompletionBeforeNextSend(Byte[] message, LazyAsyncResult lazyResult)
                at System.Net.Security.NegoState.ProcessReceivedBlob(Byte[] message, LazyAsyncResult lazyResult)
                at System.Net.Security.NegoState.StartSendBlob(Byte[] message, LazyAsyncResult lazyResult)
                at System.Net.Security.NegoState.CheckCompletionBeforeNextSend(Byte[] message, LazyAsyncResult lazyResult)
                at System.Net.Security.NegoState.ProcessReceivedBlob(Byte[] message, LazyAsyncResult lazyResult)
                at System.Net.Security.NegoState.StartSendBlob(Byte[] message, LazyAsyncResult lazyResult)
                at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)
                at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
                at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade(Stream stream, SecurityMessageProperty& remoteSecurity)
           InnerException: System.ComponentModel.Win32Exception
                HResult=-2147467259
                Message=The target principal name is incorrect
                ErrorCode=-2147467259
                NativeErrorCode=-2146893022
                InnerException:

    here is the uriI'm going to: "net.tcp://co-vm-mike01:8551/MsgService"

    Am I missing someting here? 

    Thanks,

    Mike

    Monday, September 22, 2014 10:12 PM

Answers

  • Please  make sure that you have set the following in your service's config file as following:

    <host>
         <baseAddresses>
             <add baseAddress="net.tcp://yourhostname:8051/MsgService" />
         </baseAddresses>
    </host>
    


    Or the following code in your host application:

      ServiceHost svcHost = new ServiceHost(typeof(MsgService), new Uri("http://yourhostname:8051/MsgService"));
    
    Monday, October 6, 2014 9:15 AM

All replies

  • Hi Bulldog61,

    Could you please try to post your config file here?

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 24, 2014 2:39 AM
    Moderator
  • Hi Amy,

    There is no config file it is done programatically. here is the code.

    EndpointAddress

    ep = newEndpointAddress("net.tcp://"+ maddr.Host + ":8551/MsgService");

                   

    NetTcpBindingbinding = newNetTcpBinding();

                   

    DuplexChannelFactory<IMsgService> Factory = BuildMsgFactory(binding, ep);

    Thanks

    Wednesday, September 24, 2014 1:34 PM
  • Please  make sure that you have set the following in your service's config file as following:

    <host>
         <baseAddresses>
             <add baseAddress="net.tcp://yourhostname:8051/MsgService" />
         </baseAddresses>
    </host>
    


    Or the following code in your host application:

      ServiceHost svcHost = new ServiceHost(typeof(MsgService), new Uri("http://yourhostname:8051/MsgService"));
    
    Monday, October 6, 2014 9:15 AM