URLConnection "Error occurred while receiving response from server"

I have customers on Windows reporting this error while making POST requests. Not all customers, but enough. It seems to be all POST requests with some sort of body. GET requests work fine. Server doesn’t seem to matter.

The message of the exception is

Error occurred while receiving response from server

Does anybody have any insight to what this actually means? Or how I could help my users troubleshoot this?

What versions of Windows? I wonder if it might be related to TLS version…

1 Like

Shouldn’t be, since the connection works. It’s Windows 10 anyway. 18362 in this most recent instance, but I don’t think the specific build matters.

Is the server in your hands?

I’ve considered that it could be malware protection terminating the connection, but in all cases that have been reported, users are just using Defender. So am I, and Defender doesn’t do anything like that anyway.

In this specific test, no. Though I do have users report a issue with my server that is something like “connection failed, maybe a bad url.” But the url isn’t bad and works for the overwhelming majority of users. That request is also a POST request.

Maybe it’s a firewall rule

New clue to this mystery: partial content is received by the server. In this case it’s attempting to upload a file. An initial request submits the metadata which returns a token and url, then a second request is made to that url to actually send the file content. There is definitely partial content being received. In the case I’m working with, the content was cut off after about 900,000 ASCII characters, though I’ve tested with ~1.3m characters without issue. I still have not been able to reproduce the issue.

It’s also not a consistent error either. I had one user we were working on for hours, I finally prepared a specialized build that would include the error number in the log message… and it started working for him before even installing that build. It’s bizarre.

@William_Yu Sorry to tag you directly, but this appears to be a Xojo error message. At least, it doesn’t return any Google results except for this forum post, so it’s probably a message in Xojo’s Windows URLConnection code. When you get a chance, would you mind looking at the code to see if there are any clues as to what might be triggering this?

So i wonder if this could be the length header. If you provide an upload can you post the headers?

It could be that the server is thinking some kind of length that’s incorrect?

Yeah it’s a good idea, but I already tried that. The Content-Length header is not only included by Xojo already, but it’s correct too.

The specific error is an API_RECEIVE_RESPONSE error (received as a WINHTTP_CALLBACK_STATUS_REQUEST_ERROR) but the actual error code number will not be of much help since we’re not populating it correctly (bug filed Feedback Case #61804).

2 Likes

Hi, is there a way to see which port URLConnection is using? A customer with a Firewall wants to know which port our app (made with Xojo) will use. Thanks

Did you end up figuring out what it was? I’ve been experiencing the same thing randomly with several customers as well.

Not exactly, but I think it’s a timeout issue.

OK thank you for the info.