Urlconnection.send not working on cloud

Hi all,

Just wondering if anyone has had issues with cloud sending data out via a urlconnection?

I’m doing this:

Var userdata As New JSONItem
userdata.Value("software_version") = DefineEncoding(SV, Encodings.UTF8)  
userdata.Value("trainer_first_name") = "James"
userdata.Value("trainer_last_name") = "Mullins"
userdata.Value("scenario_id") = 2
userdata.Compact = false
Var s As String = userdata.ToString
CaptureSocketInstance.SetRequestContent(s, "application/x-www-form-urlencoded")
CaptureSocketInstance.Send("POST", "http://testdomain.com/api/simulations")

I’m finding that on my local machine under debug it’s working fine and sending data to my website api endpoint.

If I upload to cloud then it’s failing silently.

Funny thing is that everything was working fine until the 5th of January and I can’t seem to find anything on my end. Works locally, doesn’t on the cloud. Could this be a security related error? The website that I’m trying to post to is on AWS. Is there a chance that xojocloud.net has been blacklisted?

Shouldn’t it be “application/json”?

CaptureSocketInstance.SetRequestContent(s, "application/json")

1 Like

Maybe, but It’s url encoded so in the past it’s worked ok. I’ll try and report back…

Hi Andrew, I did try and am seeing the same result.
The post is working from debug locally but doesn’t seem to post data from xojocloud.

J

Are you getting a NetworkException or the URLConnection.Error event?

Just to confirm, are you opening the firewall?

2 Likes

Well for one thing, an outgoing connection wouldn’t have the domain attached to it unless you specifically added it so I don’t see any way that this could be.

It looks like JSON to me. If the server got updated and now pays attention to the Content-Type header that could explain the problem.

1 Like

Hi Jason. Do I need to open the firewall for port 80? It was working last year but not this year unless something has changed on the config?

Works fine locally though so why would cloud hosting be any different?

Doesn’t appear to be

Hi James - Ah, no, you don’t need to open port 80. We’re not seeing anything with the firewall.

It looks like you’re using an API - I wonder if it started blocking you for some reason.

Different server implementations will react differently to an incorrect/unexpected Content-Type header. Some might ignore the header, others might reject the request entirely. And which one happens can change between different versions of the same server software.

I’d love to agree, but the server is the same. The api is the same. Only difference is that I’m communicating from my pc in one instance (in debugger that works) and from within a cloud hosted environment it doesn’t.

It was working perfectly and no code changes have been made.

Just found that the http status code reported from within the Xojo cloud instance is 308.

locally it’s 201.

Any reason why a redirect would be happening?

e = CaptureSocketInstance.SendSync("POST", "http://flaimcapture.com/api/simulations")
Var status As Integer = CaptureSocketInstance.HTTPStatusCode```

308 is a Permanent Redirect. You should look at the “Location” header and update the URLs that you use in your app.

In other words… something changed on the API side.

Thanks Greg,

Finally solved the issue, I was writing to http://flaimcapture.com/api/simulations and needed to send to https://flaimcapture.com/api/simulations

Something certainly changed on the API side, but the interesting thing is that the server side re-direct worked for us when testing in the debugger but didn’t work from xojocloud. Easy fix in the end but crazy to debug as it was working locally. Still not across the intricacies of why this would have worked locally but thanks for all your assistance.