# Possible bug in URLConnection

**URL:** <https://forum.xojo.com/t/possible-bug-in-urlconnection/83948>\
**Category:** Bugs and Feature Requests\
**Created:** [January 17, 2025, 9:00pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948 "2025-01-17T21:00:42Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyrone\_Daulton](https://forum.xojo.com/user_avatar/forum.xojo.com/tyrone_daulton/32/5604_2.png) [@Tyrone\_Daulton](https://forum.xojo.com/u/Tyrone_Daulton)\
**Post date:** [January 17, 2025, 9:00pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/1 "2025-01-17T21:00:42Z")

</div>

I attempt to retrieve data from a URLConnection using the get command. When the ContentReceived Event is triggered, content as string is empty for a number of URL addresses.

Curiously, this is the case when I run my code under Xojo 2024 Release 4.1. However, when the same code is run under Xojo Release 1 or older, content is not empty. See sample project.

It does not matter if .followredirects is true or false, which appears to be one change in release 4.1.

[URLConnectionTester.xojo\_binary\_project.zip](https://forum.xojo.com/uploads/short-url/i3fo83DJZuOTxqnuZJMsPSjid2x.zip) (7.8 KB)

---

<div class="post-metadata">

**Author:** ![Tyrone\_Daulton](https://forum.xojo.com/user_avatar/forum.xojo.com/tyrone_daulton/32/5604_2.png) [@Tyrone\_Daulton](https://forum.xojo.com/u/Tyrone_Daulton)\
**Post date:** [January 17, 2025, 9:04pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/2 "2025-01-17T21:04:58Z")

</div>

I should add the running under Release 4.1, content is always empty. Running under Release 1, is a bit intermittent, sometimes with content and sometimes not.

---

<div class="post-metadata">

**Author:** ![MarkusR](https://forum.xojo.com/user_avatar/forum.xojo.com/markusr/32/685_2.png) [@MarkusR](https://forum.xojo.com/u/MarkusR)\
**Post date:** [January 17, 2025, 9:17pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/3 "2025-01-17T21:17:54Z")

</div>

i got an answer at windows 11.  
you should also add the error event.  
and useful message output in the first line of a event `System.DebugLog CurrentMethodName`

 ![grafik](https://forum.xojo.com/uploads/default/original/3X/3/6/36ecd82ec3953cc8a02d9843202b63c92e44b018.png)

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [January 17, 2025, 9:18pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/4 "2025-01-17T21:18:34Z")

</div>

If I run your demo, what should I see/not see?

I get a lot of HTML when I click ‘Get Response’

---

<div class="post-metadata">

**Author:** ![brian\_franco](https://forum.xojo.com/user_avatar/forum.xojo.com/brian_franco/32/156_2.png) [@brian\_franco](https://forum.xojo.com/u/brian_franco)\
**Post date:** [January 17, 2025, 9:26pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/5 "2025-01-17T21:26:51Z")

</div>

I get same as @AlbertoD

Windows 10 x64 and Xojo 2024 4.1

---

<div class="post-metadata">

**Author:** ![Tyrone\_Daulton](https://forum.xojo.com/user_avatar/forum.xojo.com/tyrone_daulton/32/5604_2.png) [@Tyrone\_Daulton](https://forum.xojo.com/u/Tyrone_Daulton)\
**Post date:** [January 17, 2025, 9:27pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/6 "2025-01-17T21:27:09Z")

</div>

The text area displays what is returned in contents when a URLConnection ContentReceived is triggered. When contents is not empty the text area is filled with the data returned by the URL. When contents is empty (i.e., contents=“”), the text area is empty. Under Release 4.1, content is always empty. Under Release 1, I often see that contents is not empty and I am receiving data.

---

<div class="post-metadata">

**Author:** ![Tyrone\_Daulton](https://forum.xojo.com/user_avatar/forum.xojo.com/tyrone_daulton/32/5604_2.png) [@Tyrone\_Daulton](https://forum.xojo.com/u/Tyrone_Daulton)\
**Post date:** [January 17, 2025, 9:28pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/7 "2025-01-17T21:28:16Z")

</div>

I am running on a Mac OS 11.7.10

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [January 17, 2025, 9:31pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/8 "2025-01-17T21:31:45Z")

</div>

> [@Tyrone\_Daulton](#):
>
> Mac OS 11.7.10

I’m running macOS 13.7.2

Interesting that using Curl I get ‘nothing’, then if I use

```auto
curl -I https://cnbc.com/quotes/FGRIX

```

to pull the headers, I get `HTTP/2 503` for the first line.

Can you use curl and see if you get something or at least the headers?  
My guess is that the site is doing some filtering on your requests.

Edit: curl with `https://www.cnbc.com/quotes/AAPL` I get a response.

---

<div class="post-metadata">

**Author:** ![Scott\_C](https://forum.xojo.com/user_avatar/forum.xojo.com/scott_c/32/19612_2.png) [@Scott\_C](https://forum.xojo.com/u/Scott_C)\
**Post date:** [January 17, 2025, 9:44pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/9 "2025-01-17T21:44:47Z")

</div>

> [@Tyrone\_Daulton](#):
>
> Curiously, this is the case when I run my code under Xojo 2024 Release 4.1. However, when the same code is run under Xojo Release 1 or older, content is not empty.

Hi @Tyrone_Daulton

I’m not sure if you’re hoping to solve this problem just with the aid of forum members, or to have Xojo engineers looking into it.

If you want Xojo to look into this problem officially, you need to create an [Issue](https://tracker.xojo.com/xojoinc/xojo/-/issues). Describe the unexpected behaviour best you can, include your Xojo versions and OS version and your sample project.

Otherwise, it is unpredictable if and when a Xojo engineer may look at your post here.

I hope that helps.

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [January 17, 2025, 10:31pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/10 "2025-01-17T22:31:00Z")

</div>

Playing a little bit with Curl, looks like CNBC sometimes send a redirect (301) but not always (that’s why AAPL answered for me).

And sometimes the redirect takes longer.

Could be that Xojo is no longer waiting much time for redirect (compared with older versions), so you get sometimes response with older Xojo and now is always empty?

As Scott said, create an Issue for Xojo staff to review.

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [January 17, 2025, 11:56pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/11 "2025-01-17T23:56:01Z")

</div>

I tested on macOS 15.2 with Xojo 2024r4.1. I always get a response when FollowRedirects = True, but never when FollowRedirects = False. This is likely due to the source redirecting the request with HTTP status code 301. There are some instances where it seems the server takes more than two seconds to respond, but I always get a response.

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [January 18, 2025, 12:31am UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/12 "2025-01-18T00:31:51Z")

</div>

> [@Anthony\_G\_Cyphers](#):
>
> There are some instances where it seems the server takes more than two seconds to respond

I did some tests and once I was able to count to 6 before the TextArea showed the information.

Could internet speed affect in this case? Something like more than X seconds for response and URLConnection just not show anything.

Not sure if OP waited for several seconds (as other stocks respond almost instantly).

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [January 18, 2025, 12:34am UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/13 "2025-01-18T00:34:30Z")

</div>

Sure. Among many other factors.

- Connection initiated
- Server processes connection
- Send back a 301 in headers
- URLConnection processes header with 301 to get redirect URL
- URLConnection initiates new connection to redirected URL
- Server handles the request and returns the data
- URLConnection processes new headers and data

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [January 18, 2025, 1:16pm UTC](https://forum.xojo.com/t/possible-bug-in-urlconnection/83948/14 "2025-01-18T13:16:02Z")

</div>

Here’s a reference to some free stock market APIs that you will be able to use in Xojo. Everything you’ve asked to do so far is a violation of both CNBC and Dow Jones terms of service. I would suspect these services are intentionally trying to prevent you from accessing their data in this way.

[https://www.reddit.com/r/webdev/comments/151zk8y/is\_there\_any\_free\_stock\_market\_api\_that\_allows/jumxdbv/](https://www.reddit.com/r/webdev/comments/151zk8y/is_there_any_free_stock_market_api_that_allows/jumxdbv/)
