FoxPro Programming
HttpGetExAsync produce 0xc0000005 error
Gravatar is a globally recognized avatar based on your email address. HttpGetExAsync produce 0xc0000005 error
  Toni Köhler
  All
  Sep 28, 2021 @ 11:26pm

Hi Rick,

after I updating now to version 7.22 of WebConnection our application run into c0000005 error.

I build a free sample for you. Can you please run main.prg of folder and then execute the Click of Command1-Button.

http://fileshare-tk.k-advice.de/_wwTest.zip

http://fileshare-tk.k-advice.de/_wwTest2.zip && Code is from your sample: https://webconnection.west-wind.com/docs/_0js01sf51.htm#example

My understanding of HttpGetExAsync is, that I execute the HttpGetEx in own process. So my code wont stopping/waiting, the process is working in the “background”.

Why is VFP crashing, when the file will be deleted?

Is this a bug or bad handling of WebConnection on my side?

Gravatar is a globally recognized avatar based on your email address. re: HttpGetExAsync produce 0xc0000005 error
  Rick Strahl
  Toni Köhler
  Sep 29, 2021 @ 01:32pm

Most likely you don't have permissions to write the file in the location you're writing it to. Make sure that your FoxPro server has rights in the folder. If the write fails in the async operation it'll crash FoxPro (separate thread failures crash VFP hard).

These async processing in wwHttp is very rough compared to the sync operations, and doesn't provide all the features. There are lots of issues, such as crashing if the app gets closed down while async is running and any failure in the async code running in the background can crash VFP (like a file write problem of some sort). So you have to be careful with this.

These are not meant as super robust async methods - they were more for special case helpers.

A better way to do this today I think is to use async methods in .NET via wwDotnetBridge::InvokeMethodAsync() and calling System.Net.WebClient to make the async HTTP call.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: HttpGetExAsync produce 0xc0000005 error
  Toni Köhler
  Rick Strahl
  Sep 30, 2021 @ 12:02pm

Hi Rick,

I think you did not run my sample? I don't run a webserver application, it's windows-client-application and I'm shure that I have read/write access to GETENV("TEMP"). I see the file and VFP crashes directly after I delete file manually or automatically with tnSecondsBeforeDelete. In prior version of webconnection 4.35 it works without problems.

For my mind this is a bug in your code.

The wwDotNetBridge::InvokeMethodAsync I will check next time.

Gravatar is a globally recognized avatar based on your email address. re: HttpGetExAsync produce 0xc0000005 error
  Rick Strahl
  Toni Köhler
  Sep 30, 2021 @ 02:18pm

Please run the sample from the help file or provide some small code that is repeatable and self-contained that you can share here.

I ran the sample from the help file and it works fine, but as I said if you screw with the file (or permissions) while it's processing you're going to have a problem. Could also be AV perhaps putting a block/lock on the file.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: HttpGetExAsync produce 0xc0000005 error
  Toni Köhler
  Rick Strahl
  Oct 1, 2021 @ 12:43am

Hi Rick,

in my second sample the code of your codesample is inside, but you can also do this with single PRG and repeat this by FOR/NEXT. Now I played again with the focus on blocked file. I run this sample on 3 different computers and on one of them I haven't any problems. The different is, that this machine is 6 years old and not so fast like the other one.

If I work on one of my fast machines (Intel i7-10850 2,70 Ghz / 16gb RAM / SSD (NVMe) without Anti Virus and no Windows Defender) with INKEY(1), then the problem is gone. But this is not the sense of Asyn-Mode (Background). This works only if I delete the file manually. VFP crashes all the time if your background-process delete the file with tnSecondsBeforeDelete.

Hope this helps you to reproduce this problem by your side.

LOCAL loIP AS "wwHTTP"
LOCAL lcFile, lcResult, lnSeconds, llFastComputer
SET PATH TO JUSTPATH(SYS(16))
SET EXCLUSIVE OFF

llFastComputer = .F.	&& Resolve the c0000005 error, but application stops for 1 second

lnRounds= 5
FOR lnCount = 1 TO lnRounds
	CLEAR
	DO wwHTTP

	loIP = CREATEOBJECT("wwHTTP")
	loIP.HTTPConnect("www.west-wind.com")

	loIP.AddPostkey("FirstName", "Rick")
	loIP.AddPostkey("Company", TIME())
	loIP.AddPostkey("LastName", "STRAHL")

	lcFile = SYS(2023) + "\AsyncTest" + SYS(3) +".htm"
	ERASE (lcFile)

	loIP.HTTPGetExAsync("/wconnect/wc.dll?wwdemo~TestPage", lcFile, 40000, "", 10)
	loIP.HTTPClose()
	loIP = NULL

	*** The following is a simulation of some check code
	*** this could be done off a timer or some other processing
	*** that took place instead of in this poll loop

	lnSeconds = SECONDS()

	*** Simulate checking for file
	DO WHILE SECONDS() - lnSeconds < 15
		lcResult = File2Var(lcFile)
		? "Checking...", LEN(lcResult)
		IF EMPTY(lcResult)
			DOEVENTS
			LOOP
		ENDIF

		*** We got our result - let's delete the file
		*** to signal the thread we're done to kill the thread
		IF llFastComputer
			INKEY(1)
		ENDIF 
		ERASE (lcFile)

		EXIT
	ENDDO
ENDFOR 

*** Just display the result as HTML
*SHOWHTML(lcResult)
© 1996-2021