5

UPDATE LOG:

  1. Added more detail - Included the WCF Trace.

Firstly, not a lot of WCF experience, so apologies if this is an obvious error. I'm writing a simple console application, that needs to connect to a third-party SOAP web service. The WSDL supplied by the supplier is here:

http://pastebin.com/LJurv0qA

I have used this to create a Service Reference within Visual Studio 2010 (Using .NET 4.0) to create the auto-generated code behind. I have also setup the app.config for the various configurations:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="CompanyCustomConfig"
             type="Company.Common.CustomConfigSections.EncryptedSomethingQuiteStrangeCredentialsSection, Company.Common"
             />
    <section name="CompanyMachineConfig"
             type="Company.Common.CustomConfigSections.MachineEnvironmentKeySection, Company.Common"
             />
  </configSections>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="sessionMethodsSoap"
                 receiveTimeout="00:10:00"
                 closeTimeout="00:10:00"
                 openTimeout="00:10:00"
                 sendTimeout="00:10:00"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647">
          <security mode="Transport" />
        </binding>
        <binding name="sessionMethodsSoap1" />
        <binding name="recipientMethodsSoap">
          <security mode="Transport">
            <!--<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>-->
          </security>
        </binding>
        <!--<binding name="recipientMethodsSoap1" />-->
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="https:test.jsp"
          binding="basicHttpBinding" bindingConfiguration="sessionMethodsSoap"
          contract="Session.sessionMethodsSoap" name="sessionMethodsSoap" />
      <endpoint address="https:test.jsp"
          binding="basicHttpBinding" bindingConfiguration="recipientMethodsSoap"
          contract="Recipient.recipientMethodsSoap" name="recipientMethodsSoap"        />
    </client>
  </system.serviceModel>
  <appSettings>
    <add key="SomethingQuiteStrangeActionsClientBaseUrlWL0280" value="http://localhost.fiddler:13298/api/ua"/>
    <add key="SomethingQuiteStrangeActionsContentTypeWL0280" value="application/json"/>
    <add key="SomethingQuiteStrangeActionsClientBaseUrlTesting" value="http://localhost:13298/api/SomethingQuiteStrangeactions"/>
    <add key="SomethingQuiteStrangeActionsContentTypeTesting" value="application/json"/>
    <add key="SomethingQuiteStrangeDetailsClientBaseUrlLocalDevelopment" value="http://localhost.fiddler:13298/api/detailsofsomething/>
    <add key="SomethingQuiteStrangeDetailsContentTypeLocalDevelopment" value="application/json"/>
    <add key="SomethingQuiteStrangeDetailsClientBaseUrlTesting" value="http://localhost:13298/api/SomethingQuiteStrangedetails"/>
    <add key="SomethingQuiteStrangeDetailsContentTypeTesting" value="application/json"/>
    <add key="LogFileDirectoryTesting" value="C"/>
    <add key="LogFileDirectoryLocalDevelopment" value="C:\LogFiles\CRM"/>
  </appSettings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <CompanyCustomConfig>
    <EncryptedSomethingQuiteStrangeCredentials>
      <EncryptedSomethingQuiteStrangeCredential service="ThingLocalDevelopment" SomethingQuiteStrangeName="un" password="pw"/>
    </EncryptedSomethingQuiteStrangeCredentials>
  </CompanyCustomConfig>
  <CompanyMachineConfig>
    <MachineEnvironmentKeys>
      <MachineEnvironmentKey name="DEV" environment="LocalDevelopment" />
      <MachineEnvironmentKey name="SERVER" environment="Testing" />
    </MachineEnvironmentKeys>
  </CompanyMachineConfig>
</configuration>

Now on my LocalDevelopment box (i.e. my laptop) the client works fine, I'm able to connect to the thirdparties service, using their Logon() action. When i deploy my code to our Testing server, the same code and configuratio,n throws the following exception:

Log File Started: 18/11/2015 20:11:25 on machine TESTSERVER ============================================================================ 18/11/2015 20:11 >>>> *** Application Logged: Date Logged: 18/11/2015 20:11:25 Message: Issue in Client (Client.Logon()) - communication problem - Message: An error occurred while making the HTTP request to test.jsp. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server. Stack Trace:

Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Hachette.CRM.AdobeCRMService.Session.sessionMethodsSoap.Logon(LogonRequest request) at Hachette.CRM.AdobeCRMService.AdobeClient.Logon() in C:\My Documents\Hachette.CRM\Hachette.CRM.AdobeCRMService\AdobeClient.cs:line 84other: System.Collections.ListDictionaryInternal

On the advice of a commentee below, I have turned on WCF Tracing on the Server where the error is occurring. The exception is being thrown after a message has been sent over a channel

Exception Type:
System.Net.WebException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message:
The underlying connection was closed: An unexpected error occurred on a send.

Exception Type:
System.IO.IOException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message:
Received an unexpected EOF or 0 bytes from the transport stream.

Here is an image for clarity:

enter image description here

Now even though we are using HTTPS, the thirdparty doesnt require certifcates - the Logon() action provides me with a sessionId to use later on - so i presume using basicHttpBinding i fine?

Things to know:

  1. My local development box is running Windows 8.1
  2. The test server Im deploying to is running Windows Server2008 R2 Standard (SP1 installed).
  3. My Client is a .NET 4.0 C# Console App.
  4. Tried SOAP UI on the Server that is failing, using the same WSDL - the request worked and left out network, so it must be a WCF/.NET Issue on the box.
  5. In addition does the WCF Activation need to set on for apps that use WCF like mine - with added Service References and auto-generated code behind? Ours is off because it caused other sites to crash (needing Service Model 3.0.0.0):

enter image description here

garfbradaz
  • 3,424
  • 7
  • 43
  • 70
  • The actual error seems to be a timeout. `.System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at `. Since you are saying that it works in your local env, I believe this is a network issue between server and the WS host. Check the firewall settings and firewall logs. They may give you some clues. – Kosala W Nov 19 '15 at 01:08
  • @KosalaW Im getting the firewall logs looked at as we speak - i thought it might be something like that. We shall see! :P – garfbradaz Nov 19 '15 at 07:25
  • 1
    You can get a much more clear error message if you enable WCF tracing. See following article for how to http://www.codeproject.com/Articles/420538/Simple-Steps-to-Enable-Tracing-in-WCF – StackTrace Nov 20 '15 at 06:40
  • hey @StackTrace - I have done that and I will be updating the question :) It seems the Firewall isnt blocking the outgoing packets so I'm stumped. Will update when I get to work, inlcuding the *svclog files. – garfbradaz Nov 20 '15 at 07:05
  • Added more detail. I worked with our third party supplier and they confirm they are not receviing any requests from the Server App at all BUT they did receive our SOAP UI request from the same server box - this has to point to the server .net config? – garfbradaz Nov 24 '15 at 15:34
  • Is there a proxy server in the middle? You can use Fiddler to trace the commnication – Matt Nov 24 '15 at 22:22
  • @Matt: Used fiddler and it is tunnelling direct to the server I expect it to. Just times out. – garfbradaz Nov 25 '15 at 08:57
  • According to the configuration the service requires Transport security. Have you not forgot to install the certificate of provide certification information on **Test Machine**? Because this error is coming from Third party server not from WCF. – vendettamit Nov 25 '15 at 19:36

2 Answers2

1

The issue in the end was i needed .NET 4.5.1 installed on the Windows 2008 Server R2. Even though I was targeting the .NET 4.0. This fixed the issue complete and now works.

garfbradaz
  • 3,424
  • 7
  • 43
  • 70
0

Do some SSL troubleshooting. Some options:

  1. Quick attempt: There is an Stack Overflow question with the same error message "Received an unexpected EOF or 0 bytes from the transport stream" where the solution was to explicitly set the SSL version before the call:

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
    
  2. Enable the System.Net trace which might give you further clues.

  3. Use Wireshark or similar to sniff the SSL handshake.

Community
  • 1
  • 1
nodots
  • 1,450
  • 11
  • 19