Xojo URLConnect vs HTTPSecureSocket

Hi, I had posted this on TOF but was hoping for more insight how I might approach it: URLConnection - fails, Thunderclient succeeds - #20 by DerkJ - Web - Xojo Programming Forum

Essentially, the calls using URLConnection dont always ‘work’ as expected. Ones that dont, so far, do work as epected with HTTPSecureSocket but I know its dep and http 1.0 vs 1.1 but Im not sure if I should just go use a strategy that uses httpsecsock. My question is: what would you guys do?

Thanks in advance - posted the solution on TOF.

I haven’t tried either recently, but both were so inconsistent across Xojo releases and platforms that I made my own system using CURLMBS, which, even if a bit esoteric and arcane, is rock solid.

1 Like

I did the same, but found it would lock all threads which was worse than dealing with platform inconsistencies.

If you are using Christian’s plugin then you can call PerformMT which runs cURL in a preemptive thread. I think PeformMT has to be used from within a Xojo thread though.

Yeah I wish it were that simple. It’s been at least a year since I touched it, but it was definitely problematic enough that I had to switch back. I think it was something to do with making multiple requests at the same time.

This was my version: GitHub - thommcgrath/HTTPClientSocket: An HTTP client socket for Xojo that sucks less

:thinking: So it sucked more? :flushed:

Well… yeah I guess it did.

I have to ask you to clarify Thom, MBS cURL was thread blocking? I have multiple synchronous calls to make based on each call’s returned values from some endpoints so I have been instantiating subsequent calls on subclasses of URLConnect that each have a select logic which to call next. I dont like this all that much but it works. Im assuming I wouldnt run into that more with mbs tahn i am now right? I just want a backbone that I ‘know’ wont get squirrely.

Yes, the class I posted uses CURLSMBS and I ended up having blocking problems, even using PerformMT.

1 Like

Our curl class can yield, but stillstem things can block, e.g. if DNS doesn’t run asynchronous.

If you have a problem there, it may be good to do a sample via activity monitor on macOS or strace on Linux.

We’ve been using PerformMT on macOS & MS-Windows for over 5 years and have not had any noticeable blocking issues. In some cases the application has been performing 10 FTP transfers and a HTTPS request at the same time.

It is worth noting that the requests would have been mainly to servers that our customers own or have hosted in data centres.

2 Likes

How can I learn about that? It sounds like a great way to go. I have full mbs but cant find examples or docs.

Thanks Thom, this is really nice code!

Thom is so far above my level that I would not presume to be able to improve on his code, but as Christian wrote the plugin maybe he can check the code and improve it? Seems like something that would be both a high priority and a great example for MBS … if it works …

Here is a link to the MBS page:
https://www.monkeybreadsoftware.net/curl-curlsmbs-method2.shtml#22

From memory, we created a class that mimicked the HTTPSocket class that used a Xojo thread to setup cURL and call PerformMT. Xojo events were then raised on the main thread.