Hello,
the following code excerpt throws a Timeout web exception IF:
a) the POST goes over an HTTPS connection, and
b) the POST content (the byte array) is of a certain size (probably a few kilobytes)
Shorter content (<1024bytes) works fine and reach the server. But an array of 30KB or larger never reach the server. The strange thing is that everything works like expected if the connection is an ordinary HTTP.
No matter how large I set the timeout time, or whatever combination I choose for ContentLength, AllowWriteStreamBuffering or SendChunked, it always fails for byte arrays that are larger than a couple hundred bytes.
I'm using CF 2.0 on a Pocket PC 2003 2nd Ed. device. The script on the server is a ASP.NET handler. The proper certificates for SSL have all been installed on the device.
Anyone any ideas
Any help is greatly appreciated!
-Detlev
-----------------------------------------------------------
private bool PostStream( byte[] buffer, string url )
{
Uri myUri = new Uri( url );
HttpWebRequest objRequest = ( HttpWebRequest )WebRequest.Create( myUri );
objRequest.Method = "POST";
objRequest.ContentType = "application/octet-stream";
objRequest.ContentLength = buffer.Length;
objRequest.AllowWriteStreamBuffering = true;
try
{
using( BinaryWriter wr = new BinaryWriter( objRequest.GetRequestStream() ) )
{
wr.Write( buffer, 0, buffer.Length );
wr.Close();
}
}
catch( Exception )
{
return false;
}
try
{
HttpWebResponse objResponse = ( HttpWebResponse )objRequest.GetResponse();
using( StreamReader sr = new StreamReader( objResponse.GetResponseStream() ) )
{
//...
}
}
catch( WebException )
{
// the timeout is caught here...
return false;
}
}

HttpWebRequest.GetResponse() times out with SSL connections, but works with normal connection
Randine
Hi,
This is a known issue in NETCF V2. The issue will be fixed in our next service pack. For now, you may work around the issue by sending data in smaller chunks, or by setting the SendChunked property to true.
Thank you for reporting the issue.
Anthony Wong [MSFT]
dshaykewich
In the following code fragment, can you write out the buffer in chunks of 1000 bytes This should solve the problem, if it is the one we found.
using( BinaryWriter wr = new BinaryWriter( objRequest.GetRequestStream() ) )
{
int remainingBytes = buffer.Length;
while(remainingBytes > 0)
{
if(remainingBytes > 1000)
{
wr.Write( buffer, (buffer.Length - remainingBytes), 1000 );
remainingBytes -= 1000;
}
else
{
wr.Write( buffer, (buffer.Length - remainingBytes), remainingBytes);
remainingBytes = 0;
}
}
wr.Close();
}
Steve Teixeira
-Detlev