Discussion:
Wininet sending duplicate posts simultaneously - - please help!
(too old to reply)
John
2004-07-29 20:18:30 UTC
Permalink
Hello,

I have a client/server based program that occasionally uses wininet to
post information. For some reason, some of our clients, particularly
those located far from our office (we have some that are
international) are sending duplicate posts almost simultaneously. Some
clients will post the same information 5-10 times within a second!
Also, it appears this problem is limited to Windows XP.

Here is the code I've been using to post information:


int PostInfo(LPCTSTR strResource, LPCTSTR strPostInfo, CString&
strResponse)
{
CInternetSession session();
CHttpConnection* pConnection = NULL;
CHttpFile* pFile = NULL;
try
{
CHttpConnection* pConnection =
session.GetHttpConnection(AD_SERVER_ADDR,AD_SERVER_PORT);
CHttpFile* pFile =
pConnection->OpenRequest(0,strResource,NULL,1,NULL,NULL,INTERNET_FLAG_DONT_CACHE
| INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_RELOAD);
CString strHeaders = _T("Content-Type:
application/x-www-form-urlencoded");
if (pFile->SendRequest(strHeaders,(LPVOID)strPostInfo,CString(strPostInfo).GetLength()))
{
DWORD dwStatus;

pFile->QueryInfoStatusCode(dwStatus);
if (HTTP_STATUS_OK == dwStatus)
{
char szBuffer[256];
DWORD dwRead = 0;
for(;;)
{
dwRead = pFile->Read(szBuffer,255);
szBuffer[dwRead] = 0;
strResponse += szBuffer;
if (dwRead ==0)
{
break;
}
}
}
else
{
pFile->Close();
delete pFile;
pConnection->Close();
delete pConnection;
session.Close();
return -1;
}
}
pFile->Close();
delete pFile;
pConnection->Close();
delete pConnection;
}
catch(CInternetException* e)
{
#ifdef _DEBUG
e->ReportError();
WriteDebug("Internet Exception thrown!\n");
#endif
e->Delete();
return -1;
}
if (pFile != NULL)
delete pFile;
if (pConnection != NULL)
delete pConnection;
session.Close();
return 0;
}

Can anyone see anything wrong with the above code?

Thanks very much for any help!

- John
Brian Combs
2004-08-06 14:37:55 UTC
Permalink
Hello
I have never seen WinInet just randomly resend POST. I would add some
logging to your code and also try and get network trace from client box
along with WinInet log to try and see what is happening.

You can download debug builds of WinInet.Dll from the following location:
ftp://ftp.microsoft.com/PSS/Tools/Developer%20Support%20Tools/WinInet/
You should use the build number that is closest to the version of WinInet
that is on your system.

On Win ME/ Windows 2000/ Windows XP and greater OSs with Windows File
Protection

1. Configure Internet Explorer to use a default Start Page as close to the
page as possible. This eliminates much unnecessary logging that will add
additional size to the output log.
2. Close Internet Explorer as well as any other Internet-based applications
(additional applications that use WININET for connectivity may generate
extra traffic within the log).
3. Navigate to the location of where Internet Explorer is installed.
Typically this is either the \Program Files\Internet Explorer folder or the
\Program Files\Plus!\Microsoft Internet folder.
4. You must have extensions viewable so that the proper extension is
assigned to your file. You can turn on the extensions for all files by
going into the Folder Options from within Windows Explorer and choosing the
View tab and selecting to ‘Show all files’ and to not “Hide extensions of
known file types”.
5. Create a dummy file out of a new text file. Rename the file to the
following filename and extension:

IEXPLORE.EXE.LOCAL

The proper extension for this file is .local If you create this file and
you still have a Notepad icon for the file, re-do step 4 above.
6. Once the file has been created successfully, copy a suitable logging
version of WININET.DLL into the same directory as the file you created in
step 5.
7. Once the logging version of WININET is in place, open a CMD prompt.
Navigate to the location of where Internet Explorer is installed.
Typically this is either the \Program Files\Internet Explorer folder or the
\Program Files\Plus!\Microsoft Internet folder.
8. At the CMD prompt, type the following and hit <enter>:

SET WININETLOG=1

9. Now that the logging environment variable is set, you can now start the
logging by typing the following and hitting <enter>:

IEXPLORE.EXE

10. Internet Explorer should now open on the desktop and navigate to the
Start Page. It is important that you do not close either the CMD window or
Internet Explorer. As soon as Internet Explorer starts navigation, a
WININET.LOG file will be created on the desktop. Do not attempt to open
this log while it is being written to.
11. Recreate the problem. Once the behavior is observed, you can now
safely close Internet Explorer, as well as the CMD window. Logging should
cease. The log file should be zipped up and forwarded to a support
professional that has been trained to read these logs. If the log is too
large to send via Microsoft email (5mb), then it must be placed on the
FTPPSS FTP site (ftp://ftppss.microsoft.com)
12. Very Important: once logging is complete, you should remove the
logging version of WININET.DLL and the IEXPLORE.EXE.LOCAL file. Leaving
the logging version of WININET.DLL in place can affect overall browsing
performance because of the numerous checks written into that version.

TIP: For contrast purposes, it would be advisable to have a log of the
problem occurring and one of a normal condition, if possible. Also, a
Network Monitor packet trace that is taken at the same time as the WININET
log may also be beneficial when attempting to correlate network patterns
during the WININET communication.

NOTE: All of Microsoft’s operating systems from Windows 2000 and forward
support the use of IEXPLORE.EXE.LOCAL. This concept is called Dynamic Link
Library Redirection and documented online at http://msdn.microsoft.com.

NOTE: If you are using a custome WinInet application you can replace
IEXPLORE.EXE.LOCAL with your Application file name. And then run your
application from the command prompt.

NOTE: You can change where the log file is saved by setting environment
variable WininetLogFile, like this:
"set wininetlogfile=c:\temp\MyNewLog.log" with out the quotes.

Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: ***@gmail.com (John)
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| Subject: Wininet sending duplicate posts simultaneously - - please help!
| Date: 29 Jul 2004 13:18:30 -0700
| Organization: http://groups.google.com
| Lines: 85
| Message-ID: <***@posting.google.com>
| NNTP-Posting-Host: 4.46.107.72
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1091132310 17328 127.0.0.1 (29 Jul 2004
20:18:30 GMT)
| X-Complaints-To: groups-***@google.com
| NNTP-Posting-Date: Thu, 29 Jul 2004 20:18:30 +0000 (UTC)
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.s
ul.t-online.de!t-online.de!fr.ip.ndsoftware.net!proxad.net!postnews2.google.
com!not-for-mail
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.inetsdk.programming.wininet:11581
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| Hello,
|
| I have a client/server based program that occasionally uses wininet to
| post information. For some reason, some of our clients, particularly
| those located far from our office (we have some that are
| international) are sending duplicate posts almost simultaneously. Some
| clients will post the same information 5-10 times within a second!
| Also, it appears this problem is limited to Windows XP.
|
| Here is the code I've been using to post information:
|
|
| int PostInfo(LPCTSTR strResource, LPCTSTR strPostInfo, CString&
| strResponse)
| {
| CInternetSession session();
| CHttpConnection* pConnection = NULL;
| CHttpFile* pFile = NULL;
| try
| {
| CHttpConnection* pConnection =
| session.GetHttpConnection(AD_SERVER_ADDR,AD_SERVER_PORT);
| CHttpFile* pFile =
|
pConnection->OpenRequest(0,strResource,NULL,1,NULL,NULL,INTERNET_FLAG_DONT_C
ACHE
| | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_KEEP_CONNECTION |
| INTERNET_FLAG_RELOAD);
| CString strHeaders = _T("Content-Type:
| application/x-www-form-urlencoded");
| if
(pFile->SendRequest(strHeaders,(LPVOID)strPostInfo,CString(strPostInfo).GetL
ength()))
| {
| DWORD dwStatus;
|
| pFile->QueryInfoStatusCode(dwStatus);
| if (HTTP_STATUS_OK == dwStatus)
| {
| char szBuffer[256];
| DWORD dwRead = 0;
| for(;;)
| {
| dwRead = pFile->Read(szBuffer,255);
| szBuffer[dwRead] = 0;
| strResponse += szBuffer;
| if (dwRead ==0)
| {
| break;
| }
| }
| }
| else
| {
| pFile->Close();
| delete pFile;
| pConnection->Close();
| delete pConnection;
| session.Close();
| return -1;
| }
| }
| pFile->Close();
| delete pFile;
| pConnection->Close();
| delete pConnection;
| }
| catch(CInternetException* e)
| {
| #ifdef _DEBUG
| e->ReportError();
| WriteDebug("Internet Exception thrown!\n");
| #endif
| e->Delete();
| return -1;
| }
| if (pFile != NULL)
| delete pFile;
| if (pConnection != NULL)
| delete pConnection;
| session.Close();
| return 0;
| }
|
| Can anyone see anything wrong with the above code?
|
| Thanks very much for any help!
|
| - John
|

Loading...