[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I fix this Connection Socket problem in WCF?

Posted on 2009-04-17
9
Medium Priority
?
1,728 Views
Last Modified: 2012-06-27
Hi all,

We have an ASP.NET site hosted on IIS6, talking to a WCF service hosted as a Windows Service. This is over a nettcpbinding.

This generally works very nicely, but I noticed today if a few of us attempt connections, or I raise many page requests myself in quick succession it all stops and begins to time out. Once everything has finished timing out it's good to go again.

I have set

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerCall)]

above my IWcfService interface to avoid concurrency problems, but it's made no difference.

I have zipped and attached our WCF trace log where you can see it runs smoothly, then dies, and repeats this. I had to rename the file from WcfTrace.svclog to WcfTrace.svclog.txt to upload it so please change the extension back.

Many thanks
0
Comment
Question by:SWS001
  • 5
  • 3
8 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24170502
What sort of data is the service accessing ... there may be issues where multiple requests to the data are causing lockups.

Do you have Multiple Threads running in the Code? You may have a Deadlock.

0
 

Author Comment

by:SWS001
ID: 24177610
I haven't coded anything to be multi threaded per se, I was under the impression each session from IIS would get it's own instance.

It's accessing a sql 2005 database, and returning from that. I'll put a profiler on the database to have a look, but it's the same database we used to use prior to going wcf and haven't had that issue before.

Thanks
0
 

Author Comment

by:SWS001
ID: 24177794
I have this at the top of my wcf service class

    [DataContract(Namespace = "http://schemas.mycompany.com/ORS2")]
    [KnownType(typeof(System.Collections.Hashtable))]
    [KnownType(typeof(Request))]
    [KnownType(typeof(SubRequest))]
    [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerCall)]
    public class WcfService : IWcfService
    {
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:SWS001
ID: 24179443
I think it might be because I'm not closing my WcfServiceClient in any of my aspx pages...
0
 

Author Comment

by:SWS001
ID: 24182925
Another thing I've done which appears to have helped
In my app.config under ServiceBehaviours

<serviceThrottling maxConcurrentCalls="16"
maxConcurrentInstances="2147483647"
maxConcurrentSessions="64"/>
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24186607
I think it might be because I'm not closing my WcfServiceClient in any of my aspx pages..

Yeah you can run out of resources this way .. wrap it in a using block
0
 

Author Comment

by:SWS001
ID: 24188480
I see that a using statement with wcf service client can cause issues masking exceptions.

http://msdn.microsoft.com/en-us/library/aa355056.aspx
http://www.iserviceoriented.com/blog/post/Indisposable+-+WCF+Gotcha+1.aspx
http://blog.davidbarrett.net/archive/2007/11.aspx

Will I be ok for now just being careful where I close clients? I could do something like





 public partial class WcfServiceClient : IDisposable
{

    void IDisposable.Dispose() {

        if (this.State == CommunicationState.Faulted) {
            this.Abort();
        } else {
            this.Close();
        }

    }

}



and then I just start and stop my methods with a using statement right?

Thanks
0
 
LVL 12

Accepted Solution

by:
williamcampbell earned 2000 total points
ID: 24188770
Yeah give that a try

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question