Connection reset by peer

I have a REST API on my Wix site which I am accessing from an external PHP site using curl requests. Most of the time it works OK, but from time to time I get the following error:

OpenSSL SSL_read: Connection reset by peer, errno 104

I don’t think it’s to do with CURLOPT_USERAGENT in the request as I am using the browser’s user agent which normally works OK.

Any ideas?

A few questions and I will see if I can investigate more for you. I would also suggest submitting a bug report in the meantime in case you are experiencing a bug.

What version of curl are you using? Have you tried other versions to rule that out?
Does it happen on all types of requests or only certain kinds? GET, PUT, POST…
Are you attempting multiple calls in a row?

Basically something is terminating the connection, but I’m not sure what just yet. I would also recc googling that error unrelated to Wix as perhaps it’s more curl related.

Also, are you using a wix rest api or one you exposed through http functions? Can you share the api code (obscuring anything private, of course)

Thanks. I am using PHP’s curl functions, eg curl_setopt() and curl_exec(). I am running PHP 8.0.14. I am only using POST requests. Sometimes I will make two calls in a row, but the error can happen on either call. Yes, I’m using http-functions.js and the API code is at https://github.com/meeting-room-booking-system/mrbs-code/blob/main/wix/web/http-functions.js . The PHP code that calls the API is in the method http_functions() in https://github.com/meeting-room-booking-system/mrbs-code/blob/main/web/lib/MRBS/Auth/AuthWix.php .

I’ve tried googling the error but there’s not much to go on. The only suggestions seem to be either server overload or some kind of problem in the network.

How do I submit a bug report (if you think I should do that)?

One more piece of information: less frequently I occasionally get the error message “Empty reply from server”.

@olev This post explains where to submit the bug request. When you do, definitely give all of the information you added here and the verbose error output if you have it. I am also still looking for someone who may know better on my end, but I think a report may get you faster results. Let me know what they say.

Hello again! I asked around for some other thoughts on this and something to look into (unrelated to Wix so we can’t change this…) is that calls taking longer than 14 seconds will timeout and the connection will terminate. Something to look into.

If I hear any other ideas, I will let you know.

Many thanks for your help. I don’t think it’s a timeout problem as (a) my calls don’t take that long and (b) just in case they do, I put a delay of 16s in the code to see what happens and then I get an HTTP 504 response code rather than the “Connection reset by peer” error.

I’ve now raised a bug report.

Thanks for the update and yes, I thought the timeout was a long shot in your case as that generally results in a different kind of error as you suspected.

I haven’t been able to track down anyone who has knowledge of this particular error in relation the http functions in velo so definitely keep me posted when you hear back from your ticket submission

Hey did you get anywhere on this problem? I am seeing a connection reset issue with my wix blog. It’s not an API call but sounds similar. The problem only happens intermittently.

No, I never solved the problem. It got much less frequent for a bit and then came back and is still there intermittently. My suspicion is that it’s load related, either on the Wix server or possibly on my server. What makes me think that it could be related to my server is that the problem became much less frequent when I improved the efficiency of some other curl requests to a completely different server. They were taking 2-3 seconds to complete, but then I enabled gzip and the curl requests to the other server became much faster and at the same time the Wix problems became much less frequent. It may have been coincidence but I wonder if there’s a problem if you have two curl requests active at the same time.