WCF duplex service using net tcp: "Streaming security required ..."

I am writing a service that allows users to register on it and receive notifications when an event occurs. I try to do this with netTcpBinding, but keep coming up with errors even when working on the local machine.

When I try to send a notification, I disconnected, getting this error:

Stream security requires http://www.w3.org/2005/08/addressing/anonymous , but the security context has not been discussed. This is likely due to the fact that the remote endpoint does not miss the StreamSecurityBindingElement from the binding.

For testing, I place the service in the console, and it opens for me, and I can see the WSDL and run svcutil. When I start the client and try to send a notification, an error message appears.

Host App.config:

<system.serviceModel> <services> <service name="CompanyName.WebServices.InterventionService.RegistrationService" behaviorConfiguration="RegistrationServiceBehavior"> <endpoint address="http://localhost:8000/CompanyName/Registration" binding="wsDualHttpBinding" contract="CompanyName.WebServices.InterventionService.Interfaces.IRegistrationService"/> <endpoint address="net.tcp://localhost:8001/CompanyName/Registration" binding="netTcpBinding" contract="CompanyName.WebServices.InterventionService.Interfaces.IRegistrationService"/> </service> <service name="CompanyName.WebServices.InterventionService.NotificationService" behaviorConfiguration="NotificationServiceBehavior"> <endpoint address="http://localhost:8010/CompanyName/Notification" binding="wsDualHttpBinding" contract="CompanyName.WebServices.InterventionService.Interfaces.INotificationService"/> <endpoint address="net.tcp://localhost:8011/CompanyName/Notification" binding="netTcpBinding" contract="CompanyName.WebServices.InterventionService.Interfaces.INotificationService"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="RegistrationServiceBehavior"> <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8000/CompanyName/Registration"/> </behavior> <behavior name="NotificationServiceBehavior"> <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8010/CompanyName/Notification"/> </behavior> <behavior name="netTcpRegistrationServiceBehavior"> <serviceMetadata httpGetEnabled="true" httpGetUrl="net.tcp://localhost:8001/CompanyName/Registration"/> </behavior> <behavior name="netTcpNotificationServiceBehavior"> <serviceMetadata httpGetEnabled="true" httpGetUrl="net.tcp://localhost:8011/CompanyName/Notification"/> </behavior> </serviceBehaviors> </behaviors> 

Here is the App.config client:

 <system.serviceModel> <bindings> <netTcpBinding> <binding name="NetTcpBinding_IRegistrationService"> <security mode="None"> <message clientCredentialType="None"/> <transport clientCredentialType="None"/> </security> </binding> <binding name="NetTcpBinding_INotificationService"> <security mode="None"> <message clientCredentialType="None"/> <transport clientCredentialType="None"/> </security> </binding> </netTcpBinding> <wsDualHttpBinding> <binding name="WSDualHttpBinding_IRegistrationService"> <reliableSession ordered="true"/> <security mode="None"> <message clientCredentialType="None" negotiateServiceCredential="false"/> </security> </binding> <binding name="WSDualHttpBinding_INotificationService"> <reliableSession ordered="true"/> <security mode="None"> <message clientCredentialType="None" negotiateServiceCredential="false"/> </security> </binding> </wsDualHttpBinding> </bindings> <client> <endpoint address="http://localhost:8000/GPS/Registration" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IRegistrationService" contract="IRegistrationService" name="WSDualHttpBinding_IRegistrationService"> </endpoint> <endpoint address="net.tcp://localhost:8001/GPS/Registration" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IRegistrationService" contract="IRegistrationService" name="NetTcpBinding_IRegistrationService"> </endpoint> <endpoint address="http://localhost:8010/GPS/Notification" binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_INotificationService" contract="INotificationService" name="WSDualHttpBinding_INotificationService"> </endpoint> <endpoint address="net.tcp://localhost:8011/GPS/Notification" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_INotificationService" contract="INotificationService" name="NetTcpBinding_INotificationService"> </endpoint> </client> 

I missed a lot of registration code, since I'm only trying to get a notification that works right now.

It is planned to place this in a Windows service in 2003 on a server that is not part of the clientโ€™s domain (setting them up), and client computers will be in the clientโ€™s domain.

Edit:

I added bindings to the App.config host:

 <bindings> <netTcpBinding> <binding name="NetTcpBinding_IRegistrationService"> <security mode="None"> <message clientCredentialType="None"/> <transport clientCredentialType="None"/> </security> </binding> <binding name="NetTcpBinding_INotificationService"> <security mode="None"> <message clientCredentialType="None"/> <transport clientCredentialType="None"/> </security> </binding> </netTcpBinding> <wsDualHttpBinding> <binding name="WSDualHttpBinding_IRegistrationService"> <reliableSession ordered="true"/> <security mode="None"> <message clientCredentialType="None" negotiateServiceCredential="false"/> </security> </binding> <binding name="WSDualHttpBinding_INotificationService"> <reliableSession ordered="true"/> <security mode="None"> <message clientCredentialType="None" negotiateServiceCredential="false"/> </security> </binding> </wsDualHttpBinding> </bindings> 

These are still errors, and the Steam Security error message is required. Trying a small subset of this application in a new solution.

+4
source share
2 answers

Well, your problem looks like this:

  • on the server side, you use the default netTCP binding without parameters - you do not change anything on it. netTCP uses transport-level security with Windows credentials by default

  • on your client however you explicitly disable any netTCP binding protection

Thus, they do not coincide and do not agree on what to do.

Either you need to disable all security on the BOTH end - server AND client - or you just need to use secure defaults (with Windows credentials).

Mark

+9
source

I think this is one of those terrible error messages that lead you in many different directions. The above answers are correct for this case. My business was different - my security settings were identical on the client and served.

In my case, this link pointed to my flaw: http://www.netframeworkdevs.com/windows-communication-foundation-wcf/error-invoking-service-with-a-net-tcp-binding-123918.shtml .

My third-party app.config for the endpoint had bindingName as an attribute for the binding configuration name ... instead of bindingConfiguration . I do not think that there is even an attribute named bindingName on endpoint .

So ... I take that this error means "there is a WCF configuration error", possibly narrowed down to the configuration on the service side. Ugh.

+3
source

All Articles