Michel Bakker

I've set up communication for WCF. I used these configuration parts.
Server: (read from the stream)
<wsHttpBinding>
<binding
name="BindingThing"
messageEncoding="Mtom"
maxReceivedMessageSize="33554432"
/>
</wsHttpBinding>

Client: (sends to the stream)
<wsHttpBinding>
<binding name="WSHttpBinding"
messageEncoding="Mtom"
maxReceivedMessageSize="33554432"
>

<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>

My method signature is:
public void AddFile(System.IO.Stream request)

Some of my request go well. Things can be serialized and deserialized when I use a stream object. But sometimes I get the exception: "End of Stream encountered before parsing was completed." from the BinaryFormatter.Deserialize(request);.
I think I'm doing something wrong with the configuration of WCF, but I can't figure out what. Does anyone know what I'm doing wrong here


Re: Windows Communication Foundation (Indigo) WCF and message "End of Stream encountered before parsing was completed."

Kavita Kamani - MSFT

From the face of it, looks right. Is your server closing down before the client in some cases




Re: Windows Communication Foundation (Indigo) WCF and message "End of Stream encountered before parsing was completed."

Michel Bakker

Good thought. I don't believe they do. Everything is developed locally with two kinds of prototypes. The first one used IIS and the other one used the server you get with VS2005. Both servers stay online during the execution and even afterwards.
All the other communication went okay, not a single error with over 100 WCF calls. These were the same kind of calls but they didn't use Streaming, but basic parameters.
I'm going to do some more research on the matter and hopefully come back with more. Thanx for the reply!





Re: Windows Communication Foundation (Indigo) WCF and message "End of Stream encountered before parsing was completed."

Michel Bakker

This time I used Clientside: FileStream and Serverside: Image.Save. Works perfectly for small files. But when I use large files (17 mb bitmap or 7mb jpg) it gives me the following error:

An error occurred while receiving the HTTP response to http://localhost:1054/WCFService.Host/LargeFileTransfer.svc. 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.





Re: Windows Communication Foundation (Indigo) WCF and message "End of Stream encountered before parsing was completed."

Michel Bakker

So I tried the following.

Sending fake data:
byte[] binaryData = new byte[1000000];
MemoryStream stream = new MemoryStream(binaryData);
stream.Seek(0,
SeekOrigin.Begin);
LargeFileTransferClient client = new LargeFileTransferClient();
client.TransferFile(stream);

Apparently I can do this with a maximum of 3140829 bytes. After that, it will generate an error.





Re: Windows Communication Foundation (Indigo) WCF and message "End of Stream encountered before parsing was completed."

Michel Bakker

I have changed my application to stream everything to memory first. Now I don't get an end of request error anymore. Now I just get a time-out error after a minute which is ofcourse strange to have on a single machine where everything is developed, because it's not under a lot of stress during execution especially not 60 seconds no execution possible. The time-out is "random" and has no usefull information what so ever. 

Specific info:
- The timeout repeats after the first occurance.
- The calls are ALWAYS the same.
- IIS doesn't report any problems and doesn't go offline during the calls.

It's also unique because only the streaming variant is causing so much trouble again. Never ever has any other kind of WCF call created a timeout or any of the other errors I recently pointed out. To put another light on it: All the WCF callings (which are about 20) in my application are going so well it makes WCF unique to the point of perfect. But the streaming has slowed down our project with 30 hours so far and still no reliable solution. I'm guessing I'm doing something wrong over here but so far the information (errors, warnings exceptions) in WCF development which developers receive are mostly indirect, it's like trying to find a black spot on a black wall.





Re: Windows Communication Foundation (Indigo) WCF and message "End of Stream encountered before parsing was completed."

Michel Bakker

Now my IIS tells me the service has become unavailable when I try some heavy uploading. It's like I'm really abusing IIS when I do a lot of streaming and I'm being punished for it.

Can anybody tell if there is documentation explaining me more about the PRACTICE of streaming, because it's really not that easy as it has been described. It's not just a few params and then you can do whatever you want. It seriously creates problems for IIS and for the reliability. The way it's setup here right now is just useless and that's ofcourse not the practice of streaming with WCF. So I'm just wondering if documentation which helps you set up sensible structures for this purpose are out there. Because the last thing I want is to do it through FTP, because that would create a lot of dangers and doesn't connect well with application models.

Or is anybody experiencing one of these extreme problems TimeOut, IIS Service Unavailable, IIS Bad Request





Re: Windows Communication Foundation (Indigo) WCF and message "End of Stream encountered before parsing was completed."

Sajay - MSFT

You can control the different knobs on the client and the server. This could be the size of the message, the max recieve timeout, max sendtimeout etc

You can also make the transfer mode as streamed incase you dont want to buffer the whole object into the memory, ref http://blogs.msdn.com/drnick/archive/2006/03/31/565558.aspx

For general practices for large data sending/recieving you can use this http://msdn2.microsoft.com/en-us/library/ms733742.aspx

Does this help