I'm Hosting WCF Service on the localhost and the client is running in the same host, it works well when running both on the same machine but when i install the client in another machine and trying to connect to the server it fails ... here is the configuration file for the server
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="wsDualBinding">
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Metadata">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Metadata" name="ChatService.ChatManager">
<endpoint address="duplex" binding="wsDualHttpBinding" bindingConfiguration="wsDualBinding"
contract="ChatService.IChat" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:2525/chat/" />
<!--<add baseAddress="net.tcp://localhost:1717/chat/" />-->
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
the client config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="NewBinding0">
<security mode="None" />
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.10:2525/chat/duplex" binding="wsDualHttpBinding"
bindingConfiguration="NewBinding0" contract="ChatService.IChat" name="mgr" />
</client>
</system.serviceModel>
</configuration>
it gives me that error
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
wsDualHttpBinding requires the client to establish an address that the service can connect to in order to provide callbacks. This is done in the config file in the binding element, like this:
<wsDualHttpBinding name="NewBinding0"
clientBaseAddress="http://machine_name:port/Client/">
Since the client is on a different machine than the service, you'll need to specify the client's machine name.
See WSDualHttpBinding Class for more information on this binding.
Related
I have WCF service which works as windows service. Service works fine, tested with 100+ clients. But one machine works only on localhost. Service is hosted on windows server 2012 r2. Adding image of 'netstat'. On similar working server, service is listening on '0.0.0.0:88'.
Tried various endpoints '0.0.0.0:88/MyService.svc', '198.x.x.x:88/MyService.svc', 'HostName:88/MyService.svc' all work localy only.
Service config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="connectionString" value="xxxxx"/>
</appSettings>
<connectionStrings>
</connectionStrings>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="BehaviourService">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="FvsBasicHttp" receiveTimeout="00:20:00" sendTimeout="00:20:00" openTimeout="00:20:00" closeTimeout="00:20:00"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxDepth="32" maxBytesPerRead="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="FvsWebServiceWcf.FvsService" behaviorConfiguration="BehaviourService" >
<endpoint name="FvsService" address ="" binding="basicHttpBinding" bindingConfiguration="FvsBasicHttp" contract="FvsWebServiceWcf.IFvsService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://195.x.x.x:88/MyService.asmx"/>
</baseAddresses>
</host>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
Possible guess: Someone messed the machine up by setting HTTP.SYS to only listen on the localhost interface. You could check this by running the command:
netsh.exe http show iplisten
If it does return 127.0.0.1 as expected, you probably need to remove the entry with (netsh.exe http delete iplisten ipaddress=127.0.0.1). Not sure if you'd need to add 0.0.0.0 again just to get it to work again.
I have a WCF service hosted in a Windows service on Window Server 2013.
Installed and got the service running fine and I can connect using Visual Studio.
When I run my app that is consurming the service I get the open timeout exception. I had a look around the web and I added the tracing as sugested here. Self hosting wcf with nettcp exception
Looking at the log genereated I see the detail on the error.
Could not connect to net.tcp://ServerName:8001/MessagingService/service. The connection attempt lasted for a time span of 00:00:21.0691067. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ServerIP:8001.
I am using net.tcp binding and I have opened ports 8000, 8001 both inbound and outbound for the service on the server. This changed nothing. I also set the rule for the service to allow any port and that made no difference.
Server Config File
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<system.serviceModel>
<services>
<service name="EMS.Messaging.Service.ChatService" behaviorConfiguration="MessagingServiceBehaviour">
<endpoint address="" binding="netTcpBinding" contract="EMS.Messaging.Service.IChat" bindingConfiguration="tcpBinding"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://ServerName:8000/MessagingService/service" />
<add baseAddress="net.tcp://ServerName:8001/MessagingService/service" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MessagingServiceBehaviour">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceThrottling maxConcurrentSessions="100"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="tcpBinding" maxBufferSize="67108864" maxReceivedMessageSize="67108864" maxBufferPoolSize="67108864" transferMode="Buffered" closeTimeout="00:00:10"
openTimeout="00:00:10" receiveTimeout="00:20:00" sendTimeout="00:01:00" maxConnections="100" portSharingEnabled="true">
<security mode="None"/>
<readerQuotas maxArrayLength="67108864" maxBytesPerRead="67108864" maxStringContentLength="67108864" />
<reliableSession enabled="true" inactivityTimeout="00:20:00" />
</binding>
</netTcpBinding>
<customBinding>
<binding name="mexBinding">
<tcpTransport maxPendingConnections="100">
<connectionPoolSettings groupName="default" maxOutboundConnectionsPerEndpoint="100"/>
</tcpTransport>
</binding>
</customBinding>
</bindings>
</system.serviceModel>
</configuration>
Question 1: Is there a way to make setspn.exe take effects without the need to restart the computer?
Question 2: I did set the SPN and ran my WCF service on the server. The client connected using Kerberos, then I changed the Identity element at client side and tried again. I found it was using NTLM instead of Kerberos but this is fine.
When I did change the SPN in the WCF service configuration file and re-ran the service (without changing the registered SPN), I found it used Kerberos authentication at client side. why changing the identity element of WCF service doesnt make any effect?
How can this be?
NOTE: I am using fiddler to check the authentication.
Server side config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfServiceLibrary1.Service1">
<host>
<baseAddresses>
<add baseAddress = "https://FQDN:PORT/TESTSVC/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="service_binding" contract="WcfServiceLibrary1.IService1">
<identity>
<servicePrincipalName value="svc1/FQDN:PORT" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="service_binding">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Client side config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1">
<security mode="Transport" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://FQDN:PORT/TESTSVC/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="ServiceReference1.IService1" name="WSHttpBinding_IService1">
<identity>
<servicePrincipalName value="ismine/nhdc1.nhandal2.local:8730" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
I actually have two different problems depending on the way that I try to run the service that look related but show themselves in different ways. Note that the code that I am running is an EXACT duplicate of the code used in Microsofts guide with the exception of different namespaces and slightly different class names.
When I tried to run the service using this method the windows service started successfully but when it did the WCF Service Host box would pop up and it gave an error message that said there is already a listener on IP endpoint localhost:. Here is my config file when I ran this way:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service behaviorConfiguration="CfmaWcfEphemerisLibrary.ServiceBehavior"
name="CfmaWcfEphemerisLibrary.Service1">
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
contract="CfmaWcfEphemerisLibrary.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8529/Service1" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CfmaWcfEphemerisLibrary.ServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
After fighting for a while I found a suggestion that said enabling port sharing on the tcp connection might help. I tried that but when I try to start the service it fails and in the Windows Events Logs under "Application" i get an error that says:
Service cannot be started. System.ServiceModel.AddressAlreadyInUseException: There is already a listener on IP endpoint 0.0.0.0:8529. Make sure that you are not trying to use this endpoint multiple times in your application and that there are no other applications listening on this endpoint. ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.ServiceModel.Channels.SocketConnectionListener.Listen()
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.SocketConnectionListener.Listen()
at System.ServiceModel.Channels.BufferedConnectionListener.Listen()
at System.ServiceModel.Channels.ExclusiveTcpTransportManager.OnOpen()
at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
at System.ServiceModel.Channels....
I can't figure out why I'm getting a port in use exception on a port that has sharing enabled. Here is my App.config file when I try to run the service with port sharing enabled.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service behaviorConfiguration="CfmaWcfEphemerisLibrary.ServiceBehavior"
name="CfmaWcfEphemerisLibrary.Service1">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding"
contract="CfmaWcfEphemerisLibrary.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8529/Service1" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CfmaWcfEphemerisLibrary.ServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding portSharingEnabled="true" name="tcpBinding" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security>
<transport>
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
It may be the problem with using the same port for metadata exchange:
http://msdn.microsoft.com/en-us/library/aa702636.aspx
see "Sharing a port between a service endpoint and a mex endpoint using the NetTcpBinding" section.
In two words, this fixes the problem:
<endpoint address="net.tcp://localhost:8530/mex" ...>
I am constructing a simple WCF service. My web.config is the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyBasicHttpBinding">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<!-- This section is optional with the default configuration
model introduced in .NET Framework 4 -->
<service name="WcfService1.Service1" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="http://companyserver/wcftest/service1.svc"
binding="basicHttpBinding"
bindingConfiguration="MyBasicHttpBinding"
contract="WcfService1.IService1" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
When I am trying to consume the service it presents the following error message:
Content Type application/soap+xml; charset=utf-8 was not supported by service http://companyserver/wcftest/Service1.svc. The client and service bindings may be mismatched.
Check the binding configurations in your client and service. There must be a discrepancy there. For instance, are you using the same security model on both client and server?