WCF callback timeout and Visual Studio catastrophic failure - c#

A kind of stupid error, but this happened when I wanted to call client by server-side-service (WCF Duplex):
The message could not be transferred within the allotted wcf callback timeout of 00:01:00, There was no space available in the reliable channel's transfer window
Also something mysterious happened too. In the login method when I called service if user and password be wrong I find sender-callback and then call GetError method on sender to show logical error like "User is wrong". This works well, but if user and password is correct and have access, I got that error (same for all other client-side methods - in all these methods I send more data than simple strings, I was send geterror) !
Edit 2: As I say in most of the callback methods, I was send data like data-context (LINQ to SQL) data-class (list or single row). So might this be my problem or not!
(But this isn't my first time, using WCF-duplex, also with send data-struct in callback methods , I'm so astounding.)
Also after that error I got this error on,
Screen unable to process request from service http://server:15450/service.svc catastrophic failure
Edit 3:
Service configuration:
<system.serviceModel>
<services>
<service name="ContactServer.Business.ContactService"
behaviorConfiguration="ServiceBehavior">
<endpoint address=""
binding="wsDualHttpBinding"
contract="ContactServer.Business.IContactService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"
name="MexBinding"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
and Client Config
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_ContactService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1408/ContactService.svc"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ContactService"
contract="ServiceReference.ContactService" name="WSDualHttpBinding_ContactService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
More information: I use .NET 3.5 and Visual Studio 2010. Also after rising timeout on the client side I still got the same error, with 00:01:00 Time. Why did this happen?

The problem is concerning transfer of entities from a WCF-service.
For example, we have this database model:
Entity Framework:
public Item GetItem(int id)
{
var se = new SampleEntities();
return se.Items.FirstOrDefault(i => i.Id == id);
}
The code doesn't seem to be wrong, but in reality it will return the item with all related items.
var s = new SampleServiceClient();
var item = s.GetItem(1);
Assert.AreEqual(item.RelatedItems.Any(), true); //equal
It is especially dangerous if we have many-to-many relations in the database.
So lazy loading should be disabled (you can disable them just before the return):
var se = new SampleEntities();
se.ContextOptions.LazyLoadingEnabled = false;
return se.Items.FirstOrDefault(i => i.Id == id);
Linq to SQL
public Item GetItem(int id)
{
var dc = new DataClasses1DataContext();
return dc.Items.FirstOrDefault(i => i.Id == id);
}
We have an exception:
There was an error while trying to serialize parameter :GetItemResult. The InnerException message was 'Object graph for type 'WebApplication1.RelatedItem' contains cycles and cannot be serialized if reference tracking is disabled.'.
You must open DataContext diagramm and set Properties->SerializationMode->Unindirectional. Here is a more complete explanation.

Related

Object values defaulting

I converted my WCF Services today to use WSHttpBinding instead of BasicHttpBinding. It is still in the development stage and thus I am using self signed certificates. The example that I followed is located Here
After finally getting the code to work like the example illustrates (follow the examples of the configs in the code that one can download), I decided to proceed to use Channel Factories like I did before.
Now when I make a call to a WCF method, I can clearly see that the object that I am sending is populated with the expected values, but if I step into the WCF side, the values are their defaults. For example Guid's will be Empty Guid's and int's will be 0. Always.
Any idea what might be causing this? here is some of my code:
In the web.config:
<add key="ClientCertificate" value="WcfClient" />
<add key="ServerCertificate" value="WcfServer" />
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="CustomBehavior">
<clientCredentials>
<clientCertificate findValue="WcfClient"
x509FindType="FindBySubjectName"
storeLocation="CurrentUser"
storeName="My" />
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IDocumentsService" closeTimeout="00:10:00"
openTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Mtom" allowCookies="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Certificate" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:58790/DocumentsService.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IDocumentsService"
contract="DocumentsService.IDocumentsService"
name="WSHttpBinding_IDocumentsService"
behaviorConfiguration="CustomBehavior">
<identity>
<dns value="WcfServer" />
</identity>
</endpoint>
</client>
</system.serviceModel>
This is my channel factory
public static class ServiceObjects
{
public static IDocumentsService DocumentsSVC { get { return GetDocServiceClient(); } }
#region Private Members
private static WSHttpBinding _DMBinding = new WSHttpBinding("WSHttpBinding_IDocumentsService");
private static EndpointIdentity _DMIdentity = EndpointIdentity.CreateDnsIdentity(ConfigurationManager.AppSettings.Get("ServerCertificate"));
private static EndpointAddress _DMEndpoint = new EndpointAddress(new Uri(ConfigurationManager.AppSettings.Get("DocumentsService")), _DMIdentity);
private static IDocumentsService GetDocServiceClient()
{
ChannelFactory<IDocumentsService> _docSvcFactory = new ChannelFactory<IDocumentsService>(_DMBinding, _DMEndpoint);
_docSvcFactory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
_docSvcFactory.Credentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, ConfigurationManager.AppSettings.Get("ClientCertificate"));
_docSvcFactory.Credentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, ConfigurationManager.AppSettings.Get("ServerCertificate"));
return _docSvcFactory.CreateChannel();
}
#endregion
}
When I call the service, on the Client side for example:
private static Guid _UserID = (HttpContext.Current.User as Titan.Web.Classes.Identity.CustomPrincipal).UserId;
ServiceObjects.DocumentsSVC.GetDocumentsByFolderID(new DocumentRequest { CurrentUserID = _UserID })
I can see _UserID is populated, but on the server side it's not.
This is in my service's config
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="true" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security>
<message clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="Titan.WCF.Documents.DocumentsService" behaviorConfiguration="DocumentsServiceBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding" contract="Titan.WCF.Documents.IDocumentsService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DocumentsServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceCredentials>
<clientCertificate>
<!-- Remove the NoCheck in production, this is only for when we use a self signed cert -->
<authentication certificateValidationMode="PeerOrChainTrust" revocationMode="NoCheck" />
</clientCertificate>
<serviceCertificate findValue="WCfServer"
storeLocation="CurrentUser"
storeName="My"
x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Of course, since you've changed your configuration in the service you need to update the service reference so that the client too can update its configuration on its side. Unless you do that the client will keep calling the service with old configuration which it reads from its config file while the service runs with the new configuration settings.
It may be tiring, but it's the way it is.
It seems the issue lies in the way you make a call to the service using the following code:
ServiceObjects.DocumentsSVC.GetDocumentsByFolderID(new DocumentRequest { CurrentUserID = _UserID });
Here you are trying to invoke the service function without creating a proxy object of the service. And that is because you have written a static class in the service.
In a WCF service you can't use static classes. You need to create an instance of the class (service proxy object) and then invoke the service function.
I am not sure why this would make a difference, but it did.
I needed to update my service references.
A rookie mistake I guess, but why would that make a difference if the only thing I did was to change the bindings, endpoints etc?

The socket connection was aborted

I have a WCF service, that is hosted as a windows service, called by clients via proxy classes. The method in the proxy class looks like this:
public CustomerResponse GetCustomers(CustomerRequest request)
{
try
{
return Channel.GetCustomers(request);
}
catch (Exception ex)
{
throw ex;
}
}
GetCustomer presently returns me about 1000 records from my database. The problem is this:
I have ran my program on 4 different PCs, I'm only getting this error on 2 of them. The other 2 are fine, all with the same settings
On the 2 PCs with this problem, when I lowered the number of customer records in my database from 1000 to 200, the problem is resolved.
I have already max out all the settings that I know of in the config file
This is the exception message
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.9863281'.
I'm very certain it's not a time out issue as the exception is returned in less than a second.
This is my config file on the server
<services>
<service name="CustomerService" behaviorConfiguration="DefaultBehaviour">
<endpoint address="CommonService" binding="netTcpBinding" bindingConfiguration="customTcpBinding"
contract="ICustomerService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8542/CustomerService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehaviour">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
And this is the config file on the MVC project
<bindings>
<netTcpBinding>
<binding name="customTcpBinding" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<security mode="None"/>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
</binding>
</netTcpBinding>
</bindings>
<endpoint address="net.tcp://localhost:8542/CustomerService" binding="netTcpBinding" bindingConfiguration="customTcpBinding" contract="ICustomerService" name="NetTcpBinding_CustomerService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>

Impersionation like in ASP.NET for WCF Service

I've got a WebService with ASP.NET sites and WCF services in the same web.config. Until now, I was able to use the ASP.NET impersionation in the WCF services by setting
<system.web>
<compilation targetFramework="4.0" debug="false"/>
<!-- switch custom errors of-->
<identity impersonate="true"/>
<customErrors mode="Off"/>
</system.web>
However, now (for other reasons-> Cookieless Session state for the ASP.NET part) I have to set the
aspNetCompatibilityEnabled="true"
option to false. With this I loose the ASP.NET impersionation for the WCF services.
One of my WCF services needs impersionation for IO operations on the server...
I would like to know how to get the same impersionation I had before by directly defining it on the WCF service configuration.
What I have tried (unsucessfully) is to set
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
on the implementation of the methods in the WCF service and then specifying
<endpoint address="" binding="wsHttpBinding" contract="IService">
<identity>
<servicePrincipalName value="HOST/YourMachineName" />
<dns value="" />
</identity>
</endpoint>
in the web.config (obviously with the correct values for my service), as described in http://msdn.microsoft.com/en-us/library/ff650591.aspx.
However, the WCF service can not be called anymore after this... It tells me that the WsHttpBinding does not offer an identity for the contract.
Am I missing something important?
Edit: Translation of the error message:
: The contract operation '{0}' requires Windows identity for automatic impersonation. A Windows identity that represents the caller is not provided by binding ('{1}','{2}') for contract ('{3}','{4}'.
(The original error message was german...)
Try adding someting similar to this
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="DelegationBehaviour">
<clientCredentials>
<windows allowNtlm="false" allowedImpersonationLevel="Delegation"></windows>
</clientCredentials>
<dataContractSerializer maxItemsInObjectGraph="4194304"></dataContractSerializer>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_SampleWebService" >
<readerQuotas maxArrayLength="16384" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" maxStringContentLength="8192"></readerQuotas>
<security mode="TransportCredentialOnly">
<message algorithmSuite="Default" clientCredentialType="UserName"></message>
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://server/WebServices/Service/Service.svc" behaviorConfiguration="DelegationBehaviour" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_SampleWebService" contract="SampleWS" name="BasicHttpBinding_SampleEndpoint"></endpoint>
</client>
</system.serviceModel>
This is the server side code
<system.serviceModel>
<services>
<service behaviorConfiguration="CustomBehavior" name="CustomWebService">
<endpoint address="" behaviorConfiguration="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding_Service" contract="WebService"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding_Service" maxReceivedMessageSize="4194304" receiveTimeout="00:30:00">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="CustomBehavior">
<dataContractSerializer maxItemsInObjectGraph="4194304" ignoreExtensionDataObject="True"/>
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
<serviceAuthorization impersonateCallerForAllOperations="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
As well as having these over our WebMethods
<WebMethod(), OperationContract(), OperationBehavior(Impersonation:=ImpersonationOption.Required)> _
Works for us
Well, in the end I just made the binding use Windows authentication:
<security mode="TransportWithMessageCredential">
<message negotiateServiceCredential="false" clientCredentialType="Windows" algorithmSuite="Default"/>
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
</security>
and passed a specific Windows user/pwd combination in the client:
channelFactory.Credentials.Windows.ClientCredential = new NetworkCredential(#"", "", "");
channelFactory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
Additionally I had to specifically use the newly impersonated user in the code of the web service:
using (var imp = ServiceSecurityContext.Current.WindowsIdentity.Impersonate())
{
// do IO here
}
Well, the actual (underlying) question still remains:
How is it possible to emulate the ASP.NET functionality correctly...
For the moment I'm ok with the solution, however I've got the feeling that I've missed an important point about the ASP.NET impersonation.
Thanks a lot to Iain, although it wasn't exactly the correct answer, it at least got me on the right track!

large file through WCF service

Similar questions are flowing around and I looked at all of them. It appears none solve my issue.
-- UPDATE: --
I am trying to upload a document (pdf, doc, or whatever) to a database using WCF Service.
The call to the service looks like this:
using (var cw = new WCFClientWrapper<ICommonService>())
{
cw.Channel.DocumentInsert(content, filename, contentType);
}
Here is signature for the contract:
[OperationContract]
void DocumentInsert(byte[] content, string fileName, string contentType);
Please note that I am passing byte array for the content as this is what needs to be passed to store things in DB.
-- End of Update --
I can successfully upload a small file (couple kb). However, when I try to upload something larger (20kb), I get an Exception:
The formatter threw an exception while trying to deserialize the
message: Error in deserializing body of request message for operation
'DocumentInsert'. The maximum array length quota (16384) has been
exceeded while reading XML data. This quota may be increased by
changing the MaxArrayLength property on the XmlDictionaryReaderQuotas
object used when creating the XML reader. Line 1, position 31774.
The error seems to be obvious... just go and increase the MaxArrayLength. I have done that without any successful result. Below are the relevant parts from my web.configs
Client:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="SecureBehavior">
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="WSHttpBinding_Service" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="262144" messageEncoding="Text"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="2147483646" maxBytesPerRead="4096" maxNameTableCharCount="5242880" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://dev.svc.someurl.com/CommonService.svc"
binding="basicHttpBinding"
bindingConfiguration="WSHttpBinding_Service"
behaviorConfiguration="SecureBehavior"
contract="MyApp.Contracts.ServiceContracts.ICommonService"
name="MyApp.Contracts.ServiceContracts.ICommonService">
</endpoint>
</client>
</system.serviceModel>
Service:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="MyBasicHttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="MyApp.WCFServices.CommonService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="MyBasicHttpBinding"
contract="MyApp.Contracts.ServiceContracts.ICommonService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
<service name="MyApp.WCFServices.AccountService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="MyBasicHttpBinding"
contract="MyApp.Contracts.ServiceContracts.IAccountService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Attaching diagnostics shows:
Construct Service: no errors/warnings
Open Service: warning - Configuration evaluation context not found - No matching tag was found. Default endpoints added.
Listen at 'http://dev.svc.someurl.com/CommonService.svc' : no
errors/warnings
Processing message 1 : no errors/warnings
Processing Action 'http://tempuri.org/ICommonService/DocumentInsert'.
: throws exception that I wrote at the very beginning.
Any help is appreciated.
I have came across with the same exception a few months ago. To send/receive large data to/from WCF service you have to set transferMode="Streamed". When use transfermode as Buffered, it actually puts the entire file in memory before uploading/downloading. Therefore a large buffer is required on both the web client and the WCF service host.Whereas Streamed transfers can improve the scalability of a service by eliminating the need for large memory buffers. For more information on transfermode, see the MSDN article on TransferMode Enumeration
All right, after a day of struggling I finally found an issue.
I just had to make sure that the name of the tag in WCF web.config matches the namespace and the name of the service:
<service name="ServicesImplementation.WcfServices.CommonService">
Unfortunately it was not something that you guys would see based on the information that I provided.

WCF inner exception message "A registration already exists for URI 'net.tcp://....' " when trying to support a dual LAN from a WCF service

I have a self-hosted WCF service which is using the net.tcp protocol for an endpoint and it works fine on a PC with a normal LAN card.
However, I want to support PCs which have dual LAN cards and this gives me problems. I have assigned different IP addresses to the two cards (192.168.1.1 and 193.168.1.1). I then changed my app.config file to try to support the dual LAN by adding a second endpoint for the WCF service, using the second IP address. (My WCF client can handle selecting which of the two endpoint addresses to use.)
When I run the service, I get the following error message:
The ChannelDispatcher at 'net.tcp://193.168.1.1:59301/MyClientService' with contract(s) "'IMyClientService'" is unable to open its IChannelListener.
Additional information from inner exception:
A registration already exists for URI 'net.tcp://193.168.1.1:59301/MyClientService'.
Note: If I change the port # on the second endpoint in the app.config file (e.g. if i use 193.168.1.1:59302), the service starts up fine. That's a workaround, but it would be useful to be able to use the same port for both LANs, if possible.
Oh, and I tried portSharingEnabled on the binding (with the Net.TCP Port Sharing Service running) but that didn't help.
Thanks in advance...
My app.config file looks like this:
<!-- Information about assembly binding and garbage collection -->
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
<system.serviceModel>
<services>
<service name ="MyNamespace.MyClientService" behaviorConfiguration="MyServiceBehavior">
<host>
<baseAddresses>
<!-- Using TCP -->
<add baseAddress = "net.tcp://localhost:59301/MyClientService/" />
</baseAddresses>
</host>
<!-- Using TCP -->
<endpoint
address="net.tcp://192.168.1.1:59301/MyClientService"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMyClientService"
contract="MyNamespace.IMyClientService"
/>
<endpoint
address="net.tcp://193.168.1.1:59301/MyClientService"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMyClientService"
contract="MyNamespace.IMyClientService"
/>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint
address="mex"
binding="mexTcpBinding"
contract="IMetadataExchange"
/>
</service>
</services>
<bindings>
<!-- ==================================================================================== -->
<!-- TCP/IP bindings -->
<netTcpBinding>
<binding name="NetTcpBinding_IMyClientService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<!-- <serviceMetadata httpGetEnabled="True"/> -->
<serviceMetadata/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
What does "localhost" resolve to?
Looks like you're adding a base address on "localhost" and two additional endpoints, one of which will probably conflict with localhost.
Try removing the base address, see if that makes a difference...
It looks like the following section is duplicated:
<endpoint
address="net.tcp://192.168.1.1:59301/MyClientService"
binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMyClientService"
contract="MyNamespace.IMyClientService"
/>
Just try removing one of then

Categories

Resources