Discussion:
12031 Error Apache Server..........
(too old to reply)
Prab
2007-08-21 08:06:41 UTC
Permalink
Hi Guys,

Iam getting 12031 error when if(!HttpEndRequest(hRequest, NULL,
0, 0)) is executed I have tested every line debugging i find No Errors
but when the debugger reaches this line in the Below given code the
Error is generated. i have seen that this error is generated due to
SERVER_CONNECTION_TERMINATION is any chenge required in the code or
any Server Configuration has to be done. Using Apache
Server.............

HINTERNET hINet, hConnection, hData;
CHAR buffer[2048] ;
CString m_strContents ;
DWORD dwRead, dwFlags, dwStatus ;
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;

hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0 );
if ( !hINet )
{
MessageBox("InternetOpen Failed");

}


/* try
{*/
hConnection = InternetConnect( hINet, "http://ServerAddress/
uploadFile.php", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
InternetCloseHandle(hINet);
MessageBox("Failed to Connect!");

}

BufferIn.dwStructSize=sizeof(INTERNET_BUFFERS);

hRequest = HttpOpenRequest (hConnection, "PUT","/Test/Date.txt",
NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);

if (!hRequest)
{
MessageBox("Failed to open request handle!");
}

TCHAR *upFile;

upFile="d:\\Date.txt";

HANDLE hFile = CreateFile (upFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox("Failed to open local file!");
}

BufferIn.dwBufferTotal = GetFileSize (hFile, NULL);
/* printf ("File size is %d\n", BufferIn.dwBufferTotal );*/

if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, HSR_INITIATE,
0))
{
MessageBox("Error on HttpSendRequestEx!");

}

DWORD sum = 0;
do
{
if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
&dwBytesRead, NULL)))
{
MessageBox("ReadFile failed on buffer!");
break;
}
if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
&dwBytesWritten)))
{
MessageBox("File Uploading Failed!");
break;
}
sum += dwBytesWritten;
}
while (dwBytesRead == sizeof(pBuffer)) ;

CloseHandle (hFile);


if(!HttpEndRequest(hRequest, NULL, 0, 0))
{

int err = GetLastError();


MessageBox("12030 Server Terminated Connection!");
}







InternetCloseHandle(hConnection);InternetCloseHandle(hINet);
//InternetCloseHandle(hData);
Vladimir Scherbina [MVP]
2007-08-22 16:31:14 UTC
Permalink
Hello Prab,

Most likely, the problem is on server side, it terminate connection too
quickly. Contact server administrators ...
--
Vladimir, Windows SDK MVP
http://msmvps.com/blogs/v_scherbina/
Post by Prab
Hi Guys,
Iam getting 12031 error when if(!HttpEndRequest(hRequest, NULL,
0, 0)) is executed I have tested every line debugging i find No Errors
but when the debugger reaches this line in the Below given code the
Error is generated. i have seen that this error is generated due to
SERVER_CONNECTION_TERMINATION is any chenge required in the code or
any Server Configuration has to be done. Using Apache
Server.............
HINTERNET hINet, hConnection, hData;
CHAR buffer[2048] ;
CString m_strContents ;
DWORD dwRead, dwFlags, dwStatus ;
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;
hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0 );
if ( !hINet )
{
MessageBox("InternetOpen Failed");
}
/* try
{*/
hConnection = InternetConnect( hINet, "http://ServerAddress/
uploadFile.php", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
InternetCloseHandle(hINet);
MessageBox("Failed to Connect!");
}
BufferIn.dwStructSize=sizeof(INTERNET_BUFFERS);
hRequest = HttpOpenRequest (hConnection, "PUT","/Test/Date.txt",
NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (!hRequest)
{
MessageBox("Failed to open request handle!");
}
TCHAR *upFile;
upFile="d:\\Date.txt";
HANDLE hFile = CreateFile (upFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox("Failed to open local file!");
}
BufferIn.dwBufferTotal = GetFileSize (hFile, NULL);
/* printf ("File size is %d\n", BufferIn.dwBufferTotal );*/
if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, HSR_INITIATE,
0))
{
MessageBox("Error on HttpSendRequestEx!");
}
DWORD sum = 0;
do
{
if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
&dwBytesRead, NULL)))
{
MessageBox("ReadFile failed on buffer!");
break;
}
if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
&dwBytesWritten)))
{
MessageBox("File Uploading Failed!");
break;
}
sum += dwBytesWritten;
}
while (dwBytesRead == sizeof(pBuffer)) ;
CloseHandle (hFile);
if(!HttpEndRequest(hRequest, NULL, 0, 0))
{
int err = GetLastError();
MessageBox("12030 Server Terminated Connection!");
}
InternetCloseHandle(hConnection);InternetCloseHandle(hINet);
//InternetCloseHandle(hData);
Prab
2007-08-23 08:34:08 UTC
Permalink
On Aug 22, 9:31 pm, "Vladimir Scherbina [MVP]"
Post by Vladimir Scherbina [MVP]
Hello Prab,
Most likely, the problem is on server side, it terminate connection too
quickly. Contact server administrators ...
--
Post by Prab
Hi Guys,
Iam getting 12031 error when if(!HttpEndRequest(hRequest, NULL,
0, 0)) is executed I have tested every line debugging i find No Errors
but when the debugger reaches this line in the Below given code the
Error is generated. i have seen that this error is generated due to
SERVER_CONNECTION_TERMINATION is any chenge required in the code or
any Server Configuration has to be done. Using Apache
Server.............
HINTERNET hINet, hConnection, hData;
CHAR buffer[2048] ;
CString m_strContents ;
DWORD dwRead, dwFlags, dwStatus ;
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;
hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0 );
if ( !hINet )
{
MessageBox("InternetOpen Failed");
}
/* try
{*/
hConnection = InternetConnect( hINet, "http://ServerAddress/
uploadFile.php", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
InternetCloseHandle(hINet);
MessageBox("Failed to Connect!");
}
BufferIn.dwStructSize=sizeof(INTERNET_BUFFERS);
hRequest = HttpOpenRequest (hConnection, "PUT","/Test/Date.txt",
NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (!hRequest)
{
MessageBox("Failed to open request handle!");
}
TCHAR *upFile;
upFile="d:\\Date.txt";
HANDLE hFile = CreateFile (upFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox("Failed to open local file!");
}
BufferIn.dwBufferTotal = GetFileSize (hFile, NULL);
/* printf ("File size is %d\n", BufferIn.dwBufferTotal );*/
if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, HSR_INITIATE,
0))
{
MessageBox("Error on HttpSendRequestEx!");
}
DWORD sum = 0;
do
{
if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
&dwBytesRead, NULL)))
{
MessageBox("ReadFile failed on buffer!");
break;
}
if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
&dwBytesWritten)))
{
MessageBox("File Uploading Failed!");
break;
}
sum += dwBytesWritten;
}
while (dwBytesRead == sizeof(pBuffer)) ;
CloseHandle (hFile);
if(!HttpEndRequest(hRequest, NULL, 0, 0))
{
int err = GetLastError();
MessageBox("12030 Server Terminated Connection!");
}
InternetCloseHandle(hConnection);InternetCloseHandle(hINet);
//InternetCloseHandle(hData);- Hide quoted text -
- Show quoted text -
I have Tried on two to Three Systems i get the Same Error Msg
Vladimir Scherbina [MVP]
2007-08-23 09:51:48 UTC
Permalink
Post by Prab
I have Tried on two to Three Systems i get the Same Error Msg
Have you checked your client machine against firewalls, LSP's, etc?
--
Vladimir, Windows SDK MVP
http://msmvps.com/blogs/v_scherbina/
Post by Prab
On Aug 22, 9:31 pm, "Vladimir Scherbina [MVP]"
Post by Vladimir Scherbina [MVP]
Hello Prab,
Most likely, the problem is on server side, it terminate connection too
quickly. Contact server administrators ...
--
Vladimir, Windows SDK MVPhttp://msmvps.com/blogs/v_scherbina/"Prab"
Post by Prab
Hi Guys,
Iam getting 12031 error when if(!HttpEndRequest(hRequest, NULL,
0, 0)) is executed I have tested every line debugging i find No Errors
but when the debugger reaches this line in the Below given code the
Error is generated. i have seen that this error is generated due to
SERVER_CONNECTION_TERMINATION is any chenge required in the code or
any Server Configuration has to be done. Using Apache
Server.............
HINTERNET hINet, hConnection, hData;
CHAR buffer[2048] ;
CString m_strContents ;
DWORD dwRead, dwFlags, dwStatus ;
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;
hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0 );
if ( !hINet )
{
MessageBox("InternetOpen Failed");
}
/* try
{*/
hConnection = InternetConnect( hINet, "http://ServerAddress/
uploadFile.php", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
InternetCloseHandle(hINet);
MessageBox("Failed to Connect!");
}
BufferIn.dwStructSize=sizeof(INTERNET_BUFFERS);
hRequest = HttpOpenRequest (hConnection, "PUT","/Test/Date.txt",
NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (!hRequest)
{
MessageBox("Failed to open request handle!");
}
TCHAR *upFile;
upFile="d:\\Date.txt";
HANDLE hFile = CreateFile (upFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox("Failed to open local file!");
}
BufferIn.dwBufferTotal = GetFileSize (hFile, NULL);
/* printf ("File size is %d\n", BufferIn.dwBufferTotal );*/
if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, HSR_INITIATE,
0))
{
MessageBox("Error on HttpSendRequestEx!");
}
DWORD sum = 0;
do
{
if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
&dwBytesRead, NULL)))
{
MessageBox("ReadFile failed on buffer!");
break;
}
if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
&dwBytesWritten)))
{
MessageBox("File Uploading Failed!");
break;
}
sum += dwBytesWritten;
}
while (dwBytesRead == sizeof(pBuffer)) ;
CloseHandle (hFile);
if(!HttpEndRequest(hRequest, NULL, 0, 0))
{
int err = GetLastError();
MessageBox("12030 Server Terminated Connection!");
}
InternetCloseHandle(hConnection);InternetCloseHandle(hINet);
//InternetCloseHandle(hData);- Hide quoted text -
- Show quoted text -
I have Tried on two to Three Systems i get the Same Error Msg
Prab
2007-08-23 12:20:15 UTC
Permalink
On Aug 23, 2:51 pm, "Vladimir Scherbina [MVP]"
Post by Vladimir Scherbina [MVP]
Post by Prab
I have Tried on two to Three Systems i get the Same Error Msg
Have you checked your client machine against firewalls, LSP's, etc?
--
Post by Prab
On Aug 22, 9:31 pm, "Vladimir Scherbina [MVP]"
Post by Vladimir Scherbina [MVP]
Hello Prab,
Most likely, the problem is on server side, it terminate connection too
quickly. Contact server administrators ...
--
Vladimir, Windows SDK MVPhttp://msmvps.com/blogs/v_scherbina/"Prab"
Post by Prab
Hi Guys,
Iam getting 12031 error when if(!HttpEndRequest(hRequest, NULL,
0, 0)) is executed I have tested every line debugging i find No Errors
but when the debugger reaches this line in the Below given code the
Error is generated. i have seen that this error is generated due to
SERVER_CONNECTION_TERMINATION is any chenge required in the code or
any Server Configuration has to be done. Using Apache
Server.............
HINTERNET hINet, hConnection, hData;
CHAR buffer[2048] ;
CString m_strContents ;
DWORD dwRead, dwFlags, dwStatus ;
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024]; // Read from file in 1K chunks
BOOL bRead, bRet;
hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0 );
if ( !hINet )
{
MessageBox("InternetOpen Failed");
}
/* try
{*/
hConnection = InternetConnect( hINet, "http://ServerAddress/
uploadFile.php", 80, " "," ", INTERNET_SERVICE_HTTP, 0, 0 );
if ( !hConnection )
{
InternetCloseHandle(hINet);
MessageBox("Failed to Connect!");
}
BufferIn.dwStructSize=sizeof(INTERNET_BUFFERS);
hRequest = HttpOpenRequest (hConnection, "PUT","/Test/Date.txt",
NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (!hRequest)
{
MessageBox("Failed to open request handle!");
}
TCHAR *upFile;
upFile="d:\\Date.txt";
HANDLE hFile = CreateFile (upFile, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox("Failed to open local file!");
}
BufferIn.dwBufferTotal = GetFileSize (hFile, NULL);
/* printf ("File size is %d\n", BufferIn.dwBufferTotal );*/
if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, HSR_INITIATE,
0))
{
MessageBox("Error on HttpSendRequestEx!");
}
DWORD sum = 0;
do
{
if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
&dwBytesRead, NULL)))
{
MessageBox("ReadFile failed on buffer!");
break;
}
if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
&dwBytesWritten)))
{
MessageBox("File Uploading Failed!");
break;
}
sum += dwBytesWritten;
}
while (dwBytesRead == sizeof(pBuffer)) ;
CloseHandle (hFile);
if(!HttpEndRequest(hRequest, NULL, 0, 0))
{
int err = GetLastError();
MessageBox("12030 Server Terminated Connection!");
}
InternetCloseHandle(hConnection);InternetCloseHandle(hINet);
//InternetCloseHandle(hData);- Hide quoted text -
- Show quoted text -
I have Tried on two to Three Systems i get the Same Error Msg- Hide quoted text -
- Show quoted text -
I Dont have FireWall..................

Loading...