PDA

View Full Version : 404 when writing page to the requeststream for a push


phil76
12-15-2006, 11:40 AM
Hello, the following code returns a 404 not found error when I use the development MDS server, however this works fine on the simulator and localhost MDS. Its just a sample to push out a web page onto the bb browser. Any ideas why? Sounds to me like the "push" listener on the dev box isnt listening, otherwise the request wouldnt yield a 404. I didnt configure this server and Im relatively new to the MDS/PUSH thing. Any ideas what the heck it could be? The device 202e6ed6 is registered on the server btw.

string resp = push("202e6ed6", "ht" + "tp://" + "www" + ".rbc.com", "Testing");
Response.Write("PUSH RETURNED: " + resp);

private string push(string to, string href, string title)
{
HttpWebRequest contentRequest = (HttpWebRequest)WebRequest.Create(href);
HttpWebResponse contentResponse = (HttpWebResponse)contentRequest.GetResponse();
byte[] data;

if (contentResponse.StatusCode == HttpStatusCode.OK)
{
WebHeaderCollection headers = contentResponse.Headers;
Stream responseStream = contentResponse.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
data = getDataFromStream(reader);
reader.Close();

string besaddress = "mydevserver.rbc.com";
string besport = "8080";
string url = "ht" + "tp://" + besaddress + ":" + besport + "/push?DESTINATION=" + to + "&PORT=7874" + "&REQUESTURI=/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

request.Method = "POST";
request.Headers.Add("Content-Location", href);
request.Headers.Add("X-RIM-Push-Title", title);
request.Headers.Add("X-RIM-Push-Type", "Browser-Message");
request.ContentType = "text/html";
request.ContentLength = data.Length;

Stream requestStm = request.GetRequestStream();
requestStm.Write(data,0,data.Length);

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
requestStm.Close();
response.Close();
if (response.StatusCode==HttpStatusCode.OK)
{
return "pushed";
}else
{
return "failed push";
}
}else
{
return "page not found";
}

}

phil76
12-15-2006, 12:35 PM
Also, when i access the service through a browser my mds responds but not the dev one:

ht tp://localhost:8080/push?
=====================
HTTP Status 400 - PushServlet: FAILED -#06 net.rim.ippp.a.b.c.ad.iq: DESTINATION parameter is missing or null

--------------------------------------------------------------------------------

type Status report

message PushServlet: FAILED -#06 net.rim.ippp.a.b.c.ad.iq: DESTINATION parameter is missing or null

description The request sent by the client was syntactically incorrect (PushServlet: FAILED -#06 net.rim.ippp.a.b.c.ad.iq: DESTINATION parameter is missing or null ).


--------------------------------------------------------------------------------

Apache Tomcat/5.5.9

ht tp://mydevserver.rbc.com:8080/push?
==============================
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.