Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3438554
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:12:07+00:00 2026-05-18T08:12:07+00:00

I am writing WCF client for service writtern in Java by one of the

  • 0

I am writing WCF client for service writtern in Java by one of the partner. I am getting an exception when I make first service call to thier service. But subsequent request did not throw any exception. I am using console application to test this. Why is that failing on first time not other times?

Here is code how I am calling the service multiple times

for (int i = 0; i < 3; i++)
{
   ServiceClientTest();
}

Here is the Binding code

TransportBindingElement transportElement = null;
        transportElement = new HttpsTransportBindingElement();
        ((HttpsTransportBindingElement)transportElement).AuthenticationScheme = AuthenticationSchemes.Basic;

        var messegeElement = new TextMessageEncodingBindingElement
        {
            MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap11, AddressingVersion.None),
            ReaderQuotas =
                    {
                        MaxArrayLength = 200000,
                        MaxBytesPerRead = 200000,
                        MaxDepth = 200000,
                        MaxNameTableCharCount = 200000,
                        MaxStringContentLength = 200000
                    }
        };

        var binding = new CustomBinding(messegeElement, transportElement);
        return binding;

Here is the exception details of first request

Failed to score for CompanyXYZ ServiceCompany System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to https://test.intelligentcusomer.ServiceCompany.com/XYZCompanyAdapter/1.0. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. —> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. —> System.IO.IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine. —> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
— End of inner exception stack trace —
at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.HttpWebRequest.MakeMemoryStream(Stream stream)
— End of inner exception stack trace —
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
— End of inner exception 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 MyCompany.Services.Clients.ServiceCompany.XYZCompanyAdapter.process(processRequest request)
at MyCompany.Services.Clients.ServiceCompany.XYZCompanyAdapterClient.MyCompany.Services.Clients.ServiceCompany.XYZCompanyAdapter.process(processRequest request) in C:\Projects\MyCompany\MyCompany.Distribution\CustomDeliveryProcessor\Clients\XYZCompanyServiceClient.cs:line 1122
at MyCompany.Services.Clients.ServiceCompany.XYZCompanyAdapterClient.process(process process1) in C:\Projects\MyCompany\MyCompany.Distribution\CustomDeliveryProcessor\Clients\XYZCompanyServiceClient.cs:line 1129
at CustomDeliveryProcessor.CusomerDelivery.CompanyTestTest() in C:\Projects\MyCompany\MyCompany.Distribution\CustomDeliveryProcessor\CusomerDelivery.cs:line 131

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:12:07+00:00Added an answer on May 18, 2026 at 8:12 am

    I fixed this error by setting KeepAlive property to false. What I found was happened, when first request sent to the service endpoint, got 401 response from server (it is obivous because service using the basic authontication and then client sent basic authorization header in next request) that closes the connection. Default behaviour of client endpoint is to keep the connection alive. Though connection closed, client still send next request by using the same connection that already closed by the server that causes the above said error in the question. But this error won’t happen again for subsequent requests because client send request with authorization header in the first request itself. So there is no chance of 401 response. What I did to fix this issue that set Keep alive property to false. So that, after 401 response, client send another request with new connection instead of using the old connection. Here is code

    Binding binding = null;
            var transportElement = new HttpsTransportBindingElement
                                    {
                                        AuthenticationScheme = AuthenticationSchemes.Basic,
                                        KeepAliveEnabled = false,
                                    };
    
            var messegeElement = new TextMessageEncodingBindingElement
            {
                MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap11, AddressingVersion.None),
                ReaderQuotas =
                {
                    MaxArrayLength = 200000,
                    MaxBytesPerRead = 200000,
                    MaxDepth = 200000,
                    MaxNameTableCharCount = 200000,
                    MaxStringContentLength = 200000
                }
            };
            binding = new CustomBinding(messegeElement, transportElement);
    
            return binding;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a WCF client for a service (not WCF). Getting an error
I am currently writing a WCF client for a Java web service that is
I am writing jquery ajax code to call wcf service. In this case WCf
I am writing the client side for a WCF service that supports both synchronous
I'm writing a PHP client to a C#/WCF web service. The parameters for some
I am writing my first WCF service. I am trying to understand how Datacontracts
I'm writing a WCF service for the first time. The service and all of
I'm writing a client to a WCF service. This is a single app in
Exception during writing event log on host machine(Windows 2008 R2) hosting WCF Service named
I'm writing my first WCF service. I decided to write the service just as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.