473,396 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

HttpWebRequest TimeOut On an Https channel while posting data

Hello,

When I'm uploading an file to a JRun WebServer (third party) with a Windows
Forms application, l always get an TimeOut while uploading, all other request
who doesn't request an post are going ok? Why? I've tried almost everything.
I also tried the KB888528 solution but this also doesn't work.

What can the KB887563 do for me?

Machine( tried on Windows 2003 Server & WinXp)
Microsoft .NET Framework 1.1 SP1

I'll hope somebody could help me because this is very frustrating.

Thanx in advance.

Greetz,

Joey Chömpff
My Code:

private void Initialize()
{
// Create a new request to the mentioned URL.
_request = (HttpWebRequest) WebRequest.Create(_url);

_request.Headers.Set("Pragma", "no-cache");
_request.UserAgent = "Sample";
_request.Timeout = 30000;
_request.Method = "GET";
_request.ContentType="text/xml";
_request.AllowAutoRedirect = true;
_request.KeepAlive = false;
_request.CookieContainer = _cookieJar;
_request.Credentials = CredentialCache.DefaultCredentials;
ServicePointManager.CertificatePolicy = new EBatchSecurityPolicy();

if (UseProxy)
{
_proxy = (WebProxy) _request.Proxy;
_proxy.Credentials = new NetworkCredential(_proxyUserName, _proxyPassword);
_request.Proxy=_proxy;
}
}

private void AddPostData()
{
string boundary = "---------------------------" +
DateTime.Now.Ticks.ToString("x");
_request.ContentType = "multipart/form-data; boundary=" + boundary;
_request.Method = "POST";

// Build up the post message header
StringBuilder sb = new StringBuilder();
sb.Append("--");
sb.Append(boundary);
sb.Append("\r\n");
sb.Append("Content-Disposition: form-data; name=\"");
sb.Append("file");
sb.Append("\"; filename=\"");
sb.Append(_fileNameToPost);
sb.Append("\"");
sb.Append("\r\n");
sb.Append("Content-Type: application/octet-stream");
sb.Append("\r\n");
sb.Append("\r\n");

string postHeader = sb.ToString();
byte[] postHeaderBytes = Encoding.Default.GetBytes(postHeader);

// Build the trailing boundary string as a byte array
// ensuring the boundary appears on a line by itself
byte[] boundaryBytes =
Encoding.Default.GetBytes(string.Format("\r\n--{0}--\r\n",boundary));

using(MemoryStream stream = new MemoryStream())
{
// Write out our post header
stream.Write(postHeaderBytes, 0, postHeaderBytes.Length);

// Write out the file contents
byte[] buffer = new Byte[checked((uint) Math.Min(4096, (int)
_dataToPost.Length))];
int bytesRead = 0;
int totalBytesRead = 0;
while ( (bytesRead = _dataToPost.Read(buffer, 0, buffer.Length)) != 0 )
{
stream.Write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}

// Write out the trailing boundary
stream.Write(boundaryBytes, 0, boundaryBytes.Length);

long length = postHeaderBytes.Length + totalBytesRead +
boundaryBytes.Length;
_request.ContentLength = length;

using(Stream requestStream = _request.GetRequestStream())
{
stream.WriteTo(requestStream);
requestStream.Close();
}

stream.Close();
}
}

public ResponseBase GetResponse(Type responseType)
{
if (_dataToPost != null && _dataToPost.Length > 0)
AddPostData();
// Read the response
using(HttpWebResponse webResponse = (HttpWebResponse)_request.GetResponse())
{
ResponseBase response = null;
using (StreamReader sr = new
StreamReader(webResponse.GetResponseStream(), System.Text.UTF8Encoding.UTF8))
{
string responseString = sr.ReadToEnd();

using(StringReader stringReader = new StringReader(responseString))
{
response = (ResponseBase) Serializer.Read(responseType, stringReader);
stringReader.Close();
}
sr.Close();
}

webResponse.Close();
return response;
}
}

My Exception:

Message: The operation has timed-out. StackTrace: at
System.Net.HttpWebRequest.GetResponse()
at ECH.EBatch.Common.Communication.EBatchCommunicator .GetResponse(Type
responseType)
at ECH.EBatch.Common.EBatchManager.GetResponse(EBatch Service service,
String url, Type responseType, Stream dataToPost, String fileName)
at ECH.EBatch.Common.EBatchManager.UploadFile(String fileName,
EBatchService ebatchService)
at
ECH.EBatch.TestApplication.EBatchManagerTest.Uploa dOldFiles(EBatchService
service)
at ECH.EBatch.TestApplication.frmMain.btnUpload_Click (Object sender,
EventArgs e)
Nov 23 '05 #1
2 4835
I've seen that I didn't use the same encoding everywhere, but this wasnt the
solution.

I've tried to search my own post and then I saw an post from "Haacked" he
noticed something about "the Expect-100 problem". He had an url to his
WebLog who gave me a solotion of my problem
(http://haacked.com/archive/2004/05/15/449.aspx).

Thanx.

"Joey Chömpff" wrote:
Hello,

When I'm uploading an file to a JRun WebServer (third party) with a Windows
Forms application, l always get an TimeOut while uploading, all other request
who doesn't request an post are going ok? Why? I've tried almost everything.
I also tried the KB888528 solution but this also doesn't work.

What can the KB887563 do for me?

Machine( tried on Windows 2003 Server & WinXp)
Microsoft .NET Framework 1.1 SP1

I'll hope somebody could help me because this is very frustrating.

Thanx in advance.

Greetz,

Joey Chömpff
My Code:

private void Initialize()
{
// Create a new request to the mentioned URL.
_request = (HttpWebRequest) WebRequest.Create(_url);

_request.Headers.Set("Pragma", "no-cache");
_request.UserAgent = "Sample";
_request.Timeout = 30000;
_request.Method = "GET";
_request.ContentType="text/xml";
_request.AllowAutoRedirect = true;
_request.KeepAlive = false;
_request.CookieContainer = _cookieJar;
_request.Credentials = CredentialCache.DefaultCredentials;
ServicePointManager.CertificatePolicy = new EBatchSecurityPolicy();

if (UseProxy)
{
_proxy = (WebProxy) _request.Proxy;
_proxy.Credentials = new NetworkCredential(_proxyUserName, _proxyPassword);
_request.Proxy=_proxy;
}
}

private void AddPostData()
{
string boundary = "---------------------------" +
DateTime.Now.Ticks.ToString("x");
_request.ContentType = "multipart/form-data; boundary=" + boundary;
_request.Method = "POST";

// Build up the post message header
StringBuilder sb = new StringBuilder();
sb.Append("--");
sb.Append(boundary);
sb.Append("\r\n");
sb.Append("Content-Disposition: form-data; name=\"");
sb.Append("file");
sb.Append("\"; filename=\"");
sb.Append(_fileNameToPost);
sb.Append("\"");
sb.Append("\r\n");
sb.Append("Content-Type: application/octet-stream");
sb.Append("\r\n");
sb.Append("\r\n");

string postHeader = sb.ToString();
byte[] postHeaderBytes = Encoding.Default.GetBytes(postHeader);

// Build the trailing boundary string as a byte array
// ensuring the boundary appears on a line by itself
byte[] boundaryBytes =
Encoding.Default.GetBytes(string.Format("\r\n--{0}--\r\n",boundary));

using(MemoryStream stream = new MemoryStream())
{
// Write out our post header
stream.Write(postHeaderBytes, 0, postHeaderBytes.Length);

// Write out the file contents
byte[] buffer = new Byte[checked((uint) Math.Min(4096, (int)
_dataToPost.Length))];
int bytesRead = 0;
int totalBytesRead = 0;
while ( (bytesRead = _dataToPost.Read(buffer, 0, buffer.Length)) != 0 )
{
stream.Write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}

// Write out the trailing boundary
stream.Write(boundaryBytes, 0, boundaryBytes.Length);

long length = postHeaderBytes.Length + totalBytesRead +
boundaryBytes.Length;
_request.ContentLength = length;

using(Stream requestStream = _request.GetRequestStream())
{
stream.WriteTo(requestStream);
requestStream.Close();
}

stream.Close();
}
}

public ResponseBase GetResponse(Type responseType)
{
if (_dataToPost != null && _dataToPost.Length > 0)
AddPostData();
// Read the response
using(HttpWebResponse webResponse = (HttpWebResponse)_request.GetResponse())
{
ResponseBase response = null;
using (StreamReader sr = new
StreamReader(webResponse.GetResponseStream(), System.Text.UTF8Encoding.UTF8))
{
string responseString = sr.ReadToEnd();

using(StringReader stringReader = new StringReader(responseString))
{
response = (ResponseBase) Serializer.Read(responseType, stringReader);
stringReader.Close();
}
sr.Close();
}

webResponse.Close();
return response;
}
}

My Exception:

Message: The operation has timed-out. StackTrace: at
System.Net.HttpWebRequest.GetResponse()
at ECH.EBatch.Common.Communication.EBatchCommunicator .GetResponse(Type
responseType)
at ECH.EBatch.Common.EBatchManager.GetResponse(EBatch Service service,
String url, Type responseType, Stream dataToPost, String fileName)
at ECH.EBatch.Common.EBatchManager.UploadFile(String fileName,
EBatchService ebatchService)
at
ECH.EBatch.TestApplication.EBatchManagerTest.Uploa dOldFiles(EBatchService
service)
at ECH.EBatch.TestApplication.frmMain.btnUpload_Click (Object sender,
EventArgs e)

Nov 23 '05 #2
I've seen that I didn't use the same encoding everywhere, but this wasnt the
solution.

I've tried to search my own post and then I saw an post from "Haacked" he
noticed something about "the Expect-100 problem". He had an url to his
WebLog who gave me a solotion of my problem
(http://haacked.com/archive/2004/05/15/449.aspx).

Thanx.

"Joey Chömpff" wrote:
Hello,

When I'm uploading an file to a JRun WebServer (third party) with a Windows
Forms application, l always get an TimeOut while uploading, all other request
who doesn't request an post are going ok? Why? I've tried almost everything.
I also tried the KB888528 solution but this also doesn't work.

What can the KB887563 do for me?

Machine( tried on Windows 2003 Server & WinXp)
Microsoft .NET Framework 1.1 SP1

I'll hope somebody could help me because this is very frustrating.

Thanx in advance.

Greetz,

Joey Chömpff
My Code:

private void Initialize()
{
// Create a new request to the mentioned URL.
_request = (HttpWebRequest) WebRequest.Create(_url);

_request.Headers.Set("Pragma", "no-cache");
_request.UserAgent = "Sample";
_request.Timeout = 30000;
_request.Method = "GET";
_request.ContentType="text/xml";
_request.AllowAutoRedirect = true;
_request.KeepAlive = false;
_request.CookieContainer = _cookieJar;
_request.Credentials = CredentialCache.DefaultCredentials;
ServicePointManager.CertificatePolicy = new EBatchSecurityPolicy();

if (UseProxy)
{
_proxy = (WebProxy) _request.Proxy;
_proxy.Credentials = new NetworkCredential(_proxyUserName, _proxyPassword);
_request.Proxy=_proxy;
}
}

private void AddPostData()
{
string boundary = "---------------------------" +
DateTime.Now.Ticks.ToString("x");
_request.ContentType = "multipart/form-data; boundary=" + boundary;
_request.Method = "POST";

// Build up the post message header
StringBuilder sb = new StringBuilder();
sb.Append("--");
sb.Append(boundary);
sb.Append("\r\n");
sb.Append("Content-Disposition: form-data; name=\"");
sb.Append("file");
sb.Append("\"; filename=\"");
sb.Append(_fileNameToPost);
sb.Append("\"");
sb.Append("\r\n");
sb.Append("Content-Type: application/octet-stream");
sb.Append("\r\n");
sb.Append("\r\n");

string postHeader = sb.ToString();
byte[] postHeaderBytes = Encoding.Default.GetBytes(postHeader);

// Build the trailing boundary string as a byte array
// ensuring the boundary appears on a line by itself
byte[] boundaryBytes =
Encoding.Default.GetBytes(string.Format("\r\n--{0}--\r\n",boundary));

using(MemoryStream stream = new MemoryStream())
{
// Write out our post header
stream.Write(postHeaderBytes, 0, postHeaderBytes.Length);

// Write out the file contents
byte[] buffer = new Byte[checked((uint) Math.Min(4096, (int)
_dataToPost.Length))];
int bytesRead = 0;
int totalBytesRead = 0;
while ( (bytesRead = _dataToPost.Read(buffer, 0, buffer.Length)) != 0 )
{
stream.Write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}

// Write out the trailing boundary
stream.Write(boundaryBytes, 0, boundaryBytes.Length);

long length = postHeaderBytes.Length + totalBytesRead +
boundaryBytes.Length;
_request.ContentLength = length;

using(Stream requestStream = _request.GetRequestStream())
{
stream.WriteTo(requestStream);
requestStream.Close();
}

stream.Close();
}
}

public ResponseBase GetResponse(Type responseType)
{
if (_dataToPost != null && _dataToPost.Length > 0)
AddPostData();
// Read the response
using(HttpWebResponse webResponse = (HttpWebResponse)_request.GetResponse())
{
ResponseBase response = null;
using (StreamReader sr = new
StreamReader(webResponse.GetResponseStream(), System.Text.UTF8Encoding.UTF8))
{
string responseString = sr.ReadToEnd();

using(StringReader stringReader = new StringReader(responseString))
{
response = (ResponseBase) Serializer.Read(responseType, stringReader);
stringReader.Close();
}
sr.Close();
}

webResponse.Close();
return response;
}
}

My Exception:

Message: The operation has timed-out. StackTrace: at
System.Net.HttpWebRequest.GetResponse()
at ECH.EBatch.Common.Communication.EBatchCommunicator .GetResponse(Type
responseType)
at ECH.EBatch.Common.EBatchManager.GetResponse(EBatch Service service,
String url, Type responseType, Stream dataToPost, String fileName)
at ECH.EBatch.Common.EBatchManager.UploadFile(String fileName,
EBatchService ebatchService)
at
ECH.EBatch.TestApplication.EBatchManagerTest.Uploa dOldFiles(EBatchService
service)
at ECH.EBatch.TestApplication.frmMain.btnUpload_Click (Object sender,
EventArgs e)

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
9
by: Mike Cronin via DotNetMonster.com | last post by:
Hi there, Can anyone tell me what level of encryption is used when making an HTTPS POST request through an instance of the System.Net.HttpWebRequest object? Thanks much in advance! Mike...
4
by: Steven Pu | last post by:
Hi, Specifically, the website I am trying to access is, https://gmail.google.com/ I've read elsewhere that Google only uses SSL2, while .NET uses SSL3 and is not backward compatible. Is...
9
by: Michael Evanchik | last post by:
Hello all, since i wanted to use ssl and its seems easy to do so with this object. Im trying to login to a webserver (aol) for this example. But for some reason, im packet sniffing with ethreal...
1
by: Joey Chömpff | last post by:
Hello, When I'm uploading an file to a JRun WebServer (third party) with a Windows Forms application, l always get an TimeOut while uploading, all other request who doesn't request an post are...
8
by: Soeren S. Joergensen | last post by:
Hi, From a win-service I do a HttpWebRequest to a secure url with some parameters to get some simple data from a remote system used later on in a worker thread. When making the request from...
9
by: Matt Sollars | last post by:
I've exhausted all other avenues with this problem. Any help would be greatly appreciated. I am performing a simple POST via a HttpWebRequest object to an SSL URL (https://). I have attempted...
1
by: Kevin Landymore | last post by:
I have a vb.net service running under a Domain account. I'm trying to call a web service on our Mainframe (IBM CICS via SSL and Client Certificates) and after a while (1 or 2 days.. thousands of...
0
by: joshblair | last post by:
Hello, I am trying to post XML documents to a third party using the HttpWebRequest. This URL uses HTTPS (SSL) but I don't have a client certificate to deal with. Apparently they are using...
2
by: steveS | last post by:
Hi all, I'm having trouble connecting to a Java web service using HttpWebRequest. I get the error message "The request was aborted: Could not create SSL/TLS secure channel". The Java service...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.