|
-
Mar 27th, 2026, 09:51 AM
#1
Thread Starter
Addicted Member
Why did these issues occur?
I wrote a program that sits on my desktop and shows stock prices which it gets from a free on-line system. The code that gets the prices is as follows:
Code:
useUrl = siteUrl + myStuff(stockIndex).symbol + myApiKey
Try
response = Await myStockDataSource.GetAsync(useUrl) '**
response.EnsureSuccessStatusCode()
responseBody = Await response.Content.ReadAsStringAsync()
myJSON = JObject.Parse(responseBody)
Catch e As HttpRequestException
Thread.Sleep(10000)
Catch e As TaskCanceledException
Console.WriteLine("Task was canceled: " & e.Message)
End Try
When the program starts, it gets one stock price about every ten seconds and once all stock prices have been read once, it updates one stock price about every 10 minutes. The program has worked flawlessly for years.
Today was a really bad day for the stock market and I assume that there were many, many more requests being made of the on-line system than usual. When the program ran, after a while, it reported an error and crashed. I opened it in the Visual Studio and watched. The immediate window showed the following errors:
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.ArgumentNullException' in Newtonsoft.Json.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in mscorlib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in mscorlib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in mscorlib.dll
Exception thrown: 'System.Threading.Tasks.TaskCanceledException' in mscorlib.dll
My plan had been to look into this issue more closely today (since I caught the error shortly before going to bed), but the program is running just fine today. What the heck happened and more importantly, how can this issue be addressed?
-
Mar 29th, 2026, 09:33 PM
#2
Re: Why did these issues occur?
Is there any way to confirm your speculation about a much higher run on the service? The fact that it has worked fine for years, failed when you suspected that there was something unusual, then got back to working fine, does suggest that you speculation was right.
Also, were you always catching those exceptions? If so, then what was the crash? After all, you seem to be catching two of the exceptions you report.
My usual boring signature: Nothing
 
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|