I created 2 WCF endpoints, the service endpoint resides on a desktop app(with IP address 10.8.20.175); the client endpoint resides on a web-hosted application.
this is service endpoint config
<services>
<service behaviorConfiguration="NotificationServiceBehavior"
name="NotificationService">
<endpoint address="" binding="netTcpBinding" contract="INotificationService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:3337/NotificationService" />
</baseAddresses>
</host>
</service>
</services>
and this is client endpoint config
<system.serviceModel>
<client>
<endpoint address="net.tcp://10.8.20.175:3337/NotificationService"
binding="netTcpBinding" contract="INotificationService"
name="NetTcpBinding_INotificationService" />
</client>
<bindings>
<netTcpBinding>
<binding sendTimeout="00:10:00" maxReceivedMessageSize="1000000" name="NetTcpBinding_INotificationService"/>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
notice that in the endpoint address, I put the actual IP address of service endpoint. when I tested the communication between service endpoint and client endpoint on localhost, that address was localhost:3337 and the communication was good. now when I deploy the endpoint I got the following errors:
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:10:00'.
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)
The log says that the connection was forcibly closed by the remote host, that means the client endpoint actually sent request and it reached the service endpoint? I am confused at this point. I am not sure if the client endpoint can reach the service endpoint.
btw, from the client endpoint machine, I can ping the machine of service endpoint and also can do telnet on the port 3337 to the remote machine.
In my experience this indicates that your service has been reached by the client and activated. However something happened during the call that killed the reply from the service.
Best way to check would be to turn on WCF tracing for your service. This should help give you a better insight into what's happening server side.
Related
I have this scheme:
IIS
hosts: OperatorService.svc (connects to ClientService)
Global.asax (on start): hosts ClientService via ServiceHost
WPF client
connects to ClientService
If I go to OperatorService the service is activated, web application started, and ClientService is successfully hosted at http://localhost:8020/ClientService. So far so good.
I can now access the ClientService in the aforementioned URL in a browser, I can add it through Add Service Reference. It's simply there - running.
But when I try to connect via generated client (looks OK), it suddenly doesn't work. Throwing:
There was no endpoint listening at http://localhost:8020/ClientService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Moreover the OperatorService connects to this ClientService itself (it is a WsDualHttpBinding to provide notifications). It subscribes itself correctly to this service (calling a method) and it works (same URL as my WPF client).
Why can't I connect from my WPF client?
WPF client config (only relevant sections):
<client>
<endpoint address="http://localhost:8020/ClientService" binding="wsDualHttpBinding"
bindingConfiguration="DefaultBindingClientService" contract="Server.IClientService"
name="DefaultBindingClientService">
<identity>
<servicePrincipalName value="host/OHS-UPC" />
</identity>
</endpoint>
</client>
<bindings>
<wsDualHttpBinding>
<binding name="DefaultBindingClientService" />
</wsDualHttpBinding>
</bindings>
IIS hosted web.config (for ClientService)
<service name="TelPro.OHS.Server.Services.ClientService" behaviorConfiguration="UnsecuredBehavior">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="DefaultBindingClientService" contract="TelPro.OHS.Server.Services.IClientService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8020/ClientService"/>
</baseAddresses>
</host>
</service>
<wsDualHttpBinding>
<binding name="DefaultBindingClientService"/>
</wsDualHttpBinding>
<behavior name="UnsecuredBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
IIS hosted web.config (for OperatorService -> ClientService)
<client>
<endpoint address="http://localhost:8020/ClientService" binding="wsDualHttpBinding"
bindingConfiguration="DefaultBindingClientService" contract="ClientNotificationServer.IClientService"
name="DefaultBindingClientService" />
</client>
<wsDualHttpBinding>
<binding name="DefaultBindingClientService" />
</wsDualHttpBinding>
I was able to solve it by switching to port 80.
http://localhost/ClientService
Somehow that works. I've tried to add rules to port 8020 everywhere (even stopped firewall), checked any port forwarding, Azure endpoints, etc. My theory is that the problem when server is trying to connect back (callback) to client and has no rights or something. My guess would be that IIS hosted service doesn't have enough rights to connect back. If anyone can still shed some light on the why, I would gladly switch answer to them. But so far I'm just glad it works regardless the port.
I'm doing some wcf tracing on a sever with 800 clients (verbose clients) and I am seeing a lot of SocketConnection aborted after Process action 'http://tempuri.org/IConnectionRegister/ValidateUriRoute'. This is during a ** ** activity
I removed (maxed out) all possible throttling (binding, service, port sharing (both on custom binding and SMSvcHost.exe). Still a lot of random timeouts and socket aborted.
Also the 0000 activity is absolutely full (less than every second) of
"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 '10675199.02:48:05.4775807'."
"The I/O operation has been aborted because of either a thread exit or an application request"
Any help would be very much appreciate in identifying who is causing the dropping of connections.
I can also upload a sample svc trace if anyone is interested.
Stack trace of Socket Connection Abort
System.ServiceModel.Channels.SocketConnection.Abort()
System.ServiceModel.Channels.TracingConnection.Abort()
System.ServiceModel.Channels.InitialServerConnectionReader.Abort()
System.ServiceModel.Channels.ServerSessionPreambleConnectionReader.OnValidate()
......
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame()
System.Runtime.AsyncResult.Complete()
System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult.OnReceive()
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame()
System.Runtime.AsyncResult.Complete()
System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete()
<customBinding>
<binding name="externalRoutingcustomBinding">
<binaryMessageEncoding>
</binaryMessageEncoding>
<security
authenticationMode="UserNameOverTransport"
allowInsecureTransport="true"
enableUnsecuredResponse="true"
>
</security><tcpTransport>
<connectionPoolSettings groupName = "default" maxOutboundConnectionsPerEndpoint = "1000"/>
</tcpTransport>
</binding>
<service name="ZPRoutingWorkflow.ZpRoutingService">
<endpoint address="Transactions" binding="customBinding" bindingConfiguration="externalRoutingcustomBinding"
name="Transactions" contract="TopUpInterface.ITransactionsService">
<identity>
<dns value="appserver.test.com" />
</identity>
</endpoint>
<endpoint address="Retry" binding="customBinding" bindingConfiguration="externalRoutingcustomBinding" name="Retry" contract="IRetryInterface.IRetryService">
<identity>
<dns value="appserver.test.com" />
</identity>
</endpoint>
Config summary:
Multiple net.tcp services over same port hosted in iis. One of the services is a routing service implementing IRequestReplyRouter. Basically all messages go through the router and the router connects internally to the services and passes them their messages
I need some help with hosting a WCF service in WAS.
I hosted the service ok in IIS and accessed over basicHttp and wsHttp binding.
But it seems I miss something when trying to host it in WAS and access over tcp/ip.
I need to configure it for access over tcp on port 10000.
I enabled WCF activation for Non-HTTP in Windows Features
The service is published under default web site, application mywcfapp
I created a BAT file to enable net.tcp binding on port 10000 on default web site and mywcfapp as below:
%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='10000:*']
%windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/mywcfapp" /enabledProtocols:http,net.tcp
The web.config is
<services>
<service name="MyWcfService">
<clear />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
listenUriMode="Explicit" />
<endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" />
<endpoint address="net.tcp://localhost:10000/mywcfapp/mywcfapp.svc"
binding="netTcpBinding" bindingConfiguration="PortSharingBinding" contract="MyApp.IService" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="PortSharingBinding" portSharingEnabled="true">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
However, it seems I cannot access the service.
When I try to access the service with WcfTestClient with the uri
net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex
I get the following error
<Fault xmlns="http://www.w3.org/2003/05/soap-envelope">
<Code>
<Value>Sender</Value>
<Subcode><Value xmlns:a="http://www.w3.org/2005/08/addressing">a:DestinationUnreachable</Value>
</Subcode>
</Code>
<Reason><Text xml:lang="ro-RO">
The message with To 'net.tcp://localhost:10000/mywcfapp/mywcfapp.svc/mex'
cannot be processed at the receiver, due to an AddressFilter mismatch
at the EndpointDispatcher.
Check that the sender and receiver's EndpointAddresses agree.
</Text></Reason>
</Fault>
If I try to connect with url (w/o specifying port)
net.tcp://localhost/OneTest.Service/OneTest.Service.svc/mex
I get the error (kept only significant part)
Could not connect to net.tcp://localhost/mywcfapp/mywcfapp.svc/mex.
The connection attempt lasted for a time span of 00:00:02.0041146.
TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:808.
No connection could be made because the target machine actively refused it 127.0.0.1:808
This might help:
Go to IIS Manager.
Right click on the app.
Choose Manage Applications -> Advanced settings
Under Behavior, there is a field for Enabled Protocols.
Make sure it has net.tcp
If it just has http, change it to
http,net.tcp
In my current system I have a router service and over a dozen (about half use msmq, rest use tcp) WCF services hosted via IIS. I've been tasked with moving all services except for the router to a windows service. This has been accomplished using the same configurations that were present using the IIS web.config file. Here is a snippet of the previous configs (public queue for service: myservices/wcfservice):
<!--Router Service web.config-->
<client>
<endpoint address="net.msmq://localhost/MyServices/WCFService.svc" binding="netMsmqBinding" contract="*" name="IWCFService_Msmq" />
</client>
<!--Services web.config-->
<service behaviorConfiguration="SomeServiceBehavior" name="WCFService">
<endpoint binding="netMsmqBinding" name="IWCFService_Msmq"
contract="IWCFService" />
<host>
<baseAddresses>
<add baseAddress="net.msmq://localhost/MyServices/WCFService" />
</baseAddresses>
</host>
</service>
I'm confused as to why this works, as the service has a net.tcp binding and the router has msmq, and when I asked around, I was told it was "magic." I tried to do the same thing with my setup (router to windows service) using a similar configuration but get an error message:
<!--Router Service web.config-->
<client>
<endpoint address="net.msmq://localhost/MyServices/WCFService" binding="netMsmqBinding" contract="*" name="IWCFService_Msmq" />
</client>
<!--One "other" Services hosted in Windows Service app.config-->
<service behaviorConfiguration="SomeServiceBehavior" name="WCFService">
<endpoint binding="netMsmqBinding" name="IWCFService_Msmq"
contract="IWCFService" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost/MyServices/WCFService" />
</baseAddresses>
</host>
</service>
This has worked fine with all my services that are just using tcp, but when I try this with msmq and attempt to start the windows service, I get the following error in the Event Viewer:
Service cannot be started. System.InvalidOperationException: Could not find a base address that matches scheme net.msmq for the endpoint with binding NetMsmqBinding. Registered base address schemes are [net.tcp].
I'm new to msmq, so any help with be appreciated. Thanks!
Updated:
I've updated the base address in the service app.config to match the address that is in the router web.config. I tried this previously and it didn't work. I later found out it was because I didn't make the msmq itself a "Transactional Queue" (which was needed for our setup). Once this was done, everything worked out!
<!--One "other" Services hosted in Windows Service app.config-->
<service behaviorConfiguration="SomeServiceBehavior" name="WCFService">
<endpoint binding="netMsmqBinding" name="IWCFService_Msmq"
contract="IWCFService" />
<host>
<baseAddresses>
<add baseAddress="net.msmq://localhost/MyServices/WCFService" />
</baseAddresses>
</host>
</service>
Judging by the error message of the InvalidOperationException, it looks like "net.tcp" is the only enabled protocol in the Advanced Settings of your application hosted in IIS.
Is "net.msmq" an enabled protocol?
Open IIS Manager
Select your application
Click Advanced Settings in the Actions list
Add "net.msmq" to Behavior - Enabled Protocols
Why not give all of your MSMQ services their own config and all the tcp services their own? The issue is obviously it looks for a base address when you choose the binding to be msmq, and it can't find an msmq binding because all you've provided is a tcp base address binding. You can also of course add another base address that uses net.msmq inside the baseaddresses node.
I have Windows Server 2008 R2 with IIS7 on it. I deployed WCF service on it. When I specify WCF service address in browser (local or external machine) http://sbkisourcedev01/VCIndex/Calculator.svc?wsdl I am getting service description in browser. However when I am trying to add reference to the project to that service I am getting following error:
The document was understood, but it could not be processed.
- The WSDL document contains links that could not be resolved.
- There was an error downloading 'http://sbkisourcedev01/VCIndex/Calculator.svc?xsd=xsd0'.
- The underlying connection was closed: An unexpected error occurred on a receive.
- Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
- An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'http://sbkisourcedev01/VCIndex/Calculator.svc?wsdl'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://sbkisourcedev01/VCIndex/Calculator.svc?wsdl. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
I have this service running on Windows 7 and it is okay. So I believe there is something with my W2K8 IIS configuration settings.
Here is my config file:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig" />
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="serviceBehavior"
name="WCFVCIndex.Calculator">
<endpoint address=""
binding="basicHttpBinding"
contract="WCFVCIndex.ICalculator"
bindingConfiguration="basicHttpBindingConfig" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Thanks in advance.
The problem was with WCF identity permissions. The identity that is used for the application pool that hosts the WCF service must have full NTFS permissions on the %WINDIR%\temp folder. After changing that permission to my identity (LOCAL SERVICE) on C:\Windows\Temp I was able to add service reference to WCF service.
have you tried http://sbkisourcedev01/VCIndex/mex?