Raw HTTP is bad for you? And whats with wxDebugReport?!

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Raw HTTP is bad for you? And whats with wxDebugReport?!

Post by lowjoel » Sat Aug 13, 2005 1:49 pm

I have almost gone INSANE using RAW HTTP for the last 2 hours... ARGH... I can barely connect to event my own local server (http://localhost) the following code is from my DevugReport::Process:

Code: Select all

	//Gather the data
	wxString str;
	for (size_t i = 0; i < GetFilesCount(); i++)
	{
		//Get the metadata
		wxString filename, desc, contents;
		GetFile(i, &filename, &desc);
		wxFileName fn(GetDirectory(), filename);
		
		//Then pluck the file
		wxFFile file(fn.GetFullPath());
		if (file.IsOpened() && file.ReadAll(&contents))
		{
			str += filename;
			str += "=";
			str += contents;
			str += "&";
		}
	}
	str = str.Mid(0, str.Length() - 1);
	
	//Connect to my server
	wxSocketClient client;
	wxIPV4address addr;
	addr.Hostname("localhost");
	addr.Service(80);
	client.Connect(addr, false);
	
	if (!client.WaitOnConnect(10))
	{
		die("Could not connect to server");
		return false;
	}
	
	client.Write("POST /bin/error.php HTTP/1.1\r\n", 128);
	client.Write("User-Agent: ClassTools/8\r\n", 128);
	client.Write("Content-Type: application/x-www-form-urlencoded\r\n\r\n", 128);
	client.Write("Host: localhost\r\n", 128);
	client.Write(str.ToAscii(), str.Length());
	client.Write("Connection: Close\r\n", 128);
	
	Reset();
	return true;
Any reason why it should always hang and 10 secs later report thatthey can't connect to the server?..

i put the Host: directive there... tried wityh and without... both still failed (it barely went past Connect()!)

btw, is there anything i should need to set for wxDebugReport? wxFFile file(fn.GetFullPath()); always can't find the file
Last edited by lowjoel on Sun Aug 14, 2005 5:03 am, edited 1 time in total.

geon
I live to help wx-kind
I live to help wx-kind
Posts: 189
Joined: Tue Sep 07, 2004 4:10 pm
Location: Sweden, Uppsala

Post by geon » Sat Aug 13, 2005 6:17 pm

Your app will wait for the socket to connect. By some unknown reason it fails, so after 10 seconds, it times out and continues executing.

Since you use a blocking connection method, you notice this as a "hang".

remove this:

Code: Select all

client.WaitOnConnect(10)
and move this to a wxSOCKET_LOST event handler:

Code: Select all

                die("Could not connect to server");
                return false;
also move this to a wxSOCKET_CONNECTION event handler:

Code: Select all

        client.Write("POST /bin/error.php HTTP/1.1\r\n", 128);
        client.Write("User-Agent: ClassTools/8\r\n", 128);
        client.Write("Content-Type: application/x-www-form-urlencoded\r\n\r\n", 128);
        client.Write("Host: localhost\r\n", 128);
        client.Write(str.ToAscii(), str.Length());
        client.Write("Connection: Close\r\n", 128);
       
        Reset();
        return true;

Are you using threads? it is a bit tricky together with sockets. There are some info on that topic if you search the forum.

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Sat Aug 13, 2005 11:25 pm

its in my crash report uploader.... i dont wanna package curl with my app

User avatar
Ryan Norton
Moderator
Moderator
Posts: 1319
Joined: Mon Aug 30, 2004 6:01 pm

Post by Ryan Norton » Mon Aug 15, 2005 5:40 pm

lowjoel wrote:its in my crash report uploader.... i dont wanna package curl with my app
I don't see curl mentioned elsewhere here...
[Mostly retired moderator, still check in to clean up some stuff]

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Post by lowjoel » Mon Aug 15, 2005 10:20 pm

wxDebugReportUpload...

Post Reply