how to resolve http error 504 code

B

blazzerbg

I am writing i web based program, based on HttpWebRequest and
HttpWebResponse. When i want to make query to specified server with
following parameters :
--------------------------------
Server: Microsoft-IIS/5.0
Date: Mon, 31 Jan 2005 16:00:08 GMT
X-Powered-By: ASP.NET
Cache-Control: max-age=86400
Expires: Tue, 01 Feb 2005 16:00:08 GMT
Etag: "067948de247c31:994"
Set-Cookie: EGSOFT_ID=213.91.217.90-4033826192.29689773; expires=Fri,
31-Dec-2010 00:00:00 GMT; path=/
Content-Length: 0
Cache-Control: private
---------------------------
on objResponse = (HttpWebResponse)objRequest.GetResponse();
line i get following error :
-------------
INTERNET ERROR: The remote server returned an error: (504) Gateway
Timeout..
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult
asyncResult)
at System.Net.HttpWebRequest.GetResponse()
------------
My settings for request are following:

objRequest.Accept =
"application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1";

objRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.6) Gecko/20040206 Firefox/0.8";

objRequest.KeepAlive=true;

objRequest.Method = "POST";
objRequest.ContentType = "application/x-www-form-urlencoded";
an so on
Is there anybody who knows how to solve this problem ?
Please help me
 
J

Joerg Jooss

I am writing i web based program, based on HttpWebRequest and
HttpWebResponse. When i want to make query to specified server with
following parameters :
--------------------------------
Server: Microsoft-IIS/5.0
Date: Mon, 31 Jan 2005 16:00:08 GMT
X-Powered-By: ASP.NET
Cache-Control: max-age=86400
Expires: Tue, 01 Feb 2005 16:00:08 GMT
Etag: "067948de247c31:994"
Set-Cookie: EGSOFT_ID=213.91.217.90-4033826192.29689773; expires=Fri,
31-Dec-2010 00:00:00 GMT; path=/
Content-Length: 0
Cache-Control: private
---------------------------
on objResponse = (HttpWebResponse)objRequest.GetResponse();
line i get following error :
-------------
INTERNET ERROR: The remote server returned an error: (504) Gateway
Timeout..
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult
asyncResult)
at System.Net.HttpWebRequest.GetResponse()
------------
My settings for request are following:

objRequest.Accept =
"application/x-shockwave-flash,text/xml,application/xml,application/xh
tml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/j
peg,image/gif;q=0.2,*/*;q=0.1";

objRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.6) Gecko/20040206 Firefox/0.8";

objRequest.KeepAlive=true;

objRequest.Method = "POST";
objRequest.ContentType = "application/x-www-form-urlencoded";
an so on
Is there anybody who knows how to solve this problem ?
Please help me

Can you post your complete code? You're not writing to the request
stream so far...

Cheers,
 
B

blazzerbg

StreamWriter myWriter = null;

HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);

objRequest.Accept =
"application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1";

objRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.6) Gecko/20040206 Firefox/0.8";
objRequest.CookieContainer = new CookieContainer();
objRequest.KeepAlive=true;
if(sessionCookie!=null)
{
objRequest.CookieContainer = new CookieContainer();
objRequest.CookieContainer.Add(sessionCookie);
}

objRequest.Method = "POST";

objRequest.ContentLength = strPost.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
}
catch (Exception e)
{
...............
}
finally
{
myWriter.Close();
}

HttpWebResponse objResponse;
try
{
objResponse = (HttpWebResponse)objRequest.GetResponse();
}
catch (Exception ex)
{
...........
}

CookieCollection cookieCol=objResponse.Cookies;
if(cookieCol!=null)
{
if(sessionCookie==null)
{
sessionCookie=cookieCol;
}
else
{
sessionCookie.Add(cookieCol);
}
}
using (StreamReader sr = new
StreamReader(objResponse.GetResponseStream()) )
{
try
{
result = sr.ReadToEnd();
}
catch (Exception ex)
{
.......................
}

// Close and clean up the StreamReader
sr.Close();
}

this is my code almost!
I get an Exception on objResponse =
(HttpWebResponse)objRequest.GetResponse();
i don't know why any ideas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top