WCF error: the underlying connection was closed an unexpected error occurred on a receive

I don’t like to post solution as comment industry, strategies, patterns… But this solution gave me happiness. I want to share it because these error has so many reasons to happen I haven’t found solution anywhere.

I had the folowing problem:

System.Exception: An error occurred while receiving the HTTP response to http://soaAdress.com. 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..

which datails:

the underlying connection was closed an unexpected error occurred on a receive

I thought my client application was fine because it closes the connection. Last time I had problem with WCF calls, the calls stopped at 11º one because we can’t keep a stabilished connection to perform more than 10 calls. But this time I couldn’t close. The service contract has 4 operations:

[OperationContract(IsOneWay = false)]
[TransactionFlow(TransactionFlowOption.NotAllowed)]
myEntity GetComission(long id);

[OperationContract(IsOneWay = false)]
[TransactionFlow(TransactionFlowOption.NotAllowed)]
myEntity GetComissionPartial(long id);

[OperationContract(IsOneWay = false)]
[TransactionFlow(TransactionFlowOption.NotAllowed)]
myEntity GetComissionAuto(long id);

[OperationContract(IsOneWay = true)]
void CloseOderProcess(Contracts.CloseMessageOrder input);

The dump file was terrible to read, but I found something:

“The message could not be processed. This is most likely because the action
‘http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT/Cancel’ is incorrect or
because the message contains an invalid or expired security context token or
because there is a mismatch between bindings. The security context token
would be invalid
if the service aborted the channel due to inactivity. To
prevent the service from aborting idle sessions prematurely increase the
Receive timeout on the service endpoint’s binding.”

It let me to a conclusion, if the service operation is IsOneWay = true, I shouldn’t close it. The service wouldn’t have the security token anymore as there is a very short connection between service and consumer and the message is operated asynchronously as stated in the contract. So I removed the .close operation and things are working now.

CodeSmith Insight

CodeSmith is a very nice tool I love to use. Helps a lot! For many years they ruled code generation practices, but now the company has been seriously threatened by T4 which comes natively inside Microsoft Visual Studio (even hidden in 2005/2008).

CodeSmith Insight

In response to that, they now release a new product on SaaS based called Codesmith Insight. Insight has a lot of promisses like:

  • Help Desk – manages support emails and questions submitted directly from your application or web site
  • Issue Tracker – tracks feature requests, defect reports and manages priority based on votes
  • Error Reporting Service – easily report and organize errors received directly from your application or web site

Take a look at the website www.codesmithinsight.com/ I liked the product but I believe that should be cheaper. Most companies has such buddle and many startup may have difficulties. Something between 300MB ~ 5GB at cost of $10 is affordable in the most developing countries in the world.

IT professionals in Brazil must now be registered

As lawyers, the Brazilian IT professional will need to be registered in a federal counselor. They will possess a number indicating has higher level degree and authorization to work in software development and all other areas. Time experience will be considered in the initial phase.

A lot of people were dreaming about it for more than one decade. Especially for the ones who went to university. It happens that many professionals changed the degree diploma for technical certifications in a day-to-day basis experience due to the market’s steam. And most of those professionals without high level education wages equally or more than the ones whose possess the high level degree.

Apparently for these reason it is common to hear people decreasing the importance of a high level degree in favor of an indubitable “competence” and technical certifications like Microsoft, Sun, CISCO among others.

Of course time and experience rule our professional’s lives but the timeline to be a good professional might be leaned after computer science or other bsc. degree’s course.
The certifications are important too. It demonstrates the professional skills to deal with certain technical product. But that isn’t enough to make you solid through this turbulent and changeable industry.

I have a similar post in portuguese language at Cairo Noleto’s blog.

All Over the World

All over the world,
There’s more than meets the eye
land and sea to share,
red yellow black and white
All over the world,
There’s darkness and there’s light
sad stories are told
But it’s good to be alive

Spy Vs. Spy

“Unable to find assembly”

A few days ago my service provider changed from windows 2003 32bit to 64bit. I’ve been in hell doing a lot of extra configuration to get my asp.net application working in the 64bit environment. In fact, no one less than the windows service could give so much problems. All about dll references…

I’ve got so many error messages and after going deeper, the last one was “Unable to find assembly”. Hell…

Google here and there… I found out that to work in 64bit environment, all .net projects has to be homogeneous regarding the target platform.

If the deployment environment is 32bit, it’s ok. You can do any mess and mix AnyCPU and x86 platforms types. But it the deployment environment is 64bit you may need to set up all your projects to x86 or x64.

But, why change to 64bit plataform? Gaurav Seth’s WebLog is nice guy which has answred I lot of my basic questions. Please, follow the links:

Cross compilation in the 64-bit .NET Framework world for platform specific features

Moving from 32-bit to 64-bit application development on .NET Framework

Is 64-bit a superior platform as compared to the 32-bit platform?

Follow

Get every new post delivered to your Inbox.