1

I have a webservice, that gives me a list of mails to send. It works fine on localhost, but not in production.

My webservice should be accessible without any limit at all. It's not safe at all, but frankly, at this point, I don't care about it at all.

I got these errors :

I've been at it the whole day, and I fear I don't remember which modification I did for which error.

The latest error I got is... a lame timeout, without innerexception. But, the funny thing is : I have configured every timeout to be 10 hours, and I get the timeout after a few seconds.

My web.config (server) has this (actually, it has 4 webservices, but I left only the one I'm trying to use now) :

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="wsHttpBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferPoolSize="20000000" useDefaultWebProxy="true">
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
                </security>
            </binding>
            <binding name="NoSecurityBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferPoolSize="20000000" useDefaultWebProxy="true">
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="CentresInteretBehavior">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" />
                <serviceCredentials>
                    <windowsAuthentication allowAnonymousLogons="true" />
                </serviceCredentials>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="CentresInteretBehavior" name="CentresInteret">
            <endpoint address="" binding="wsHttpBinding" contract="ICentresInteret" bindingConfiguration="NoSecurityBinding">
                <identity>
                    <dns value="localhost" />
                    <userPrincipalName value=".\ASPNET" />
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
    </services>
</system.serviceModel>

My app.config (client) has this (same thing : multiple WS, only one called) :

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_ICentresInteret" closeTimeout="10:00:00"
                openTimeout="10:00:00" receiveTimeout="10:00:00" sendTimeout="10:00:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="200000000"
                    maxArrayLength="200000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="10:00:00" enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="false"
                        algorithmSuite="Default" establishSecurityContext="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://www.ourserver.com/WebServices/CentresInteret.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICentresInteret"
            contract="CentresInteretService.ICentresInteret" name="WSHttpBinding_ICentresInteret">
            <identity>
                <dns value="localhost" />
                <userPrincipalName value=".\ASPNET" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

The server trace gets me this, after just a few seconds (about 10-15) on the red line (please ask me if you need another line) :

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
    <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
        <EventID>131076</EventID>
        <Type>3</Type>
        <SubType Name="Error">0</SubType>
        <Level>2</Level>
        <TimeCreated SystemTime="2011-11-28T17:46:26.6525694Z" />
        <Source Name="System.ServiceModel" />
        <Correlation ActivityID="{f624ff35-a8ae-4636-bd46-2138207af7a1}" />
        <Execution ProcessName="w3wp" ProcessID="20424" ThreadID="7" />
        <Channel />
        <Computer>SRV-WEB-01</Computer>
    </System>
    <ApplicationData>
        <TraceData>
            <DataItem>
                <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
                    <TraceIdentifier>http://msdn.microsoft.com/fr-FR/library/System.ServiceModel.Diagnostics.TraceHandledException.aspx</TraceIdentifier>
                    <Description>Traitement d’une exception.</Description>
                    <AppDomain>/LM/W3SVC/4/ROOT-1-129669759749681489</AppDomain>
                    <Exception>
                        <ExceptionType>System.Net.WebException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
                        <Message>Le délai d'attente de l'opération a expiré.</Message>
                        <StackTrace>
                            à System.Net.HttpWebRequest.GetResponse()
                            à CentresInteret.RecupererContenuMail(Int32 contact_id, Int32 frequence_id, Int32 organisme_id) dans D:\...\App_Code\WebServices\CentresInteret.vb:ligne 181
                            à CentresInteret.GetEmails(Boolean PrendreEnCompteFrequence) dans D:\...\App_Code\WebServices\CentresInteret.vb:ligne 87
                            à SyncInvokeGetEmails(Object , Object[] , Object[] )
                            à System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp;amp; outputs)
                            à System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
                        </StackTrace>
                        <ExceptionString>
                            System.Net.WebException: Le délai d'attente de l'opération a expiré.
                            à System.Net.HttpWebRequest.GetResponse()
                            à CentresInteret.RecupererContenuMail(Int32 contact_id, Int32 frequence_id, Int32 organisme_id) dans D:\...\App_Code\WebServices\CentresInteret.vb:ligne 181
                            à CentresInteret.GetEmails(Boolean PrendreEnCompteFrequence) dans D:\...\App_Code\WebServices\CentresInteret.vb:ligne 87
                            à SyncInvokeGetEmails(Object , Object[] , Object[] )
                            à System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp;amp; outputs)
                            à System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp;amp; rpc)
                            à System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
                        </ExceptionString>
                    </Exception>
                </TraceRecord>
            </DataItem>
        </TraceData>
    </ApplicationData>
</E2ETraceEvent>

Please please pretty please, have an idea. I'm all out of them. And I'm going slightly mad.

Thanks !

Edit : solved ! In CentresInteret.vb at line 181, there is :

    Dim req As HttpWebRequest = WebRequest.Create(pageModele)
    req.Timeout = 10000
    Dim resp As HttpWebResponse = req.GetResponse() ' throws the error

I added a zero in the timeout, and now it works ! Apparently, 10 seconds of timeout weren't enough...

thomasb
  • 5,816
  • 10
  • 57
  • 92
  • Are you able to get to the MEX endpoint (i.e. if you add "?wsdl" to the end of the URL) in a web browser? How about the actual .svc URL in a web browser? – CodingWithSpike Nov 22 '11 at 18:47
  • Yes, those work fine. I can get to the service declaration with WcfTestClient, but calling a method throws the same errors. – thomasb Nov 23 '11 at 08:43
  • Have you tried enabling full WCF Trace Logging on both the client and the server? It will usually give some pretty detailed information, if your call gets into the WCF service layers at all. See: http://msdn.microsoft.com/en-us/library/ms733025.aspx – CodingWithSpike Nov 23 '11 at 17:56
  • I added the trace on the server (not found how to do it on the client). – thomasb Nov 28 '11 at 18:02
  • Ok I'll try and go figure this out because I've had a problem like this before. Just to check you aren't doing anything weird, in your service. It's just plain vanilla WCF? And you generated your proxy in VS2010? – albertjan Nov 28 '11 at 18:07
  • Do I read correctly that you don't care about security right? – albertjan Nov 28 '11 at 19:27
  • @the_ajp : it's vanilla WCF, yes. I added a service reference in my project (visual studio 2008), so it's a VS generated proxy. It's not that I don't care about security, it's that I want it to work, and we'll figure out security problems later. – thomasb Nov 29 '11 at 08:45

1 Answers1

2

If this trace was from your server (not the client) then I am curious about the error:

CentresInteret.RecupererContenuMail(Int32 contact_id, Int32 frequence_id, Int32 organisme_id) dans D:...\App_Code\WebServices\CentresInteret.vb:ligne 181

It looks like the CentresInteret.RecupererContenuMail() method is one of the methods in your code? If so, what is line 181 of the file CentresInteret.vb doing? It looks like it might be getting a timeout while querying something? Maybe its doing a DB call or a call to another web service on that line?

This part of the exception:

System.Net.WebException: Le délai d'attente de l'opération a expiré. à System.Net.HttpWebRequest.GetResponse()

Makes it look like your web service code is making another web request to another service, and might be timing out. If oyu are querying another service (like Exchange or some POP3 mail server) then its timeout might be 10-15 seconds, and that timeout bubbling up to your WCF client (though as the_ajp mentioned, it should be wrapped in a FaultException at the client.)

CodingWithSpike
  • 42,906
  • 18
  • 101
  • 138
  • I'd expect to see a faultexception on the client. Maybe @cosmo0 could confirm that. – albertjan Nov 28 '11 at 19:31
  • Thanks, I must have been tired not to look at this line... I solved it : it tried to call a file using httpwebrequest, and it timed out. I added a zero in the request's timeout, and it works. Thanks ! Now, I "only" have to implement security... :P – thomasb Nov 29 '11 at 09:31