1

I have read a lot, if not all the posts, on timeouts for web requests and the solutions provided have not worked. I am getting orders from Big Commerce and then updating the Big Commerce status code. I can update 2 orders and then I timeout on the third, every single time regardless of day of week or time of day.

App.Config file has:

```
<system.web>
    <httpRuntime executionTimeout="180" />
</system.web>
```

Code:

```
    Try
        Dim strJSON As String = "{""status_id"": 9}"
        Dim postBytes As Byte() = System.Text.Encoding.UTF8.GetBytes(strJSON)
        For i As Integer = 0 To dto.Rows.Count - 1
            strWebOrder = dto.Rows(i).Item("WebOrder")
            Dim strHttp As String = "https://api.bigcommerce.com/stores/storeid/v2/orders/" & strWebOrder
            Dim request As HttpWebRequest = DirectCast(WebRequest.Create(strHttp), HttpWebRequest)
            request.Accept = "application/json"
            request.ContentType = "application/json"
            request.Headers("X-Auth-Token") = strAuthToken
            request.Timeout = 10000
            request.AllowWriteStreamBuffering = False
            request.SendChunked = True
            request.Method = "PUT"
            Dim postStream As Stream = request.GetRequestStream()
            postStream.Write(postBytes, 0, postBytes.Length)
            Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
            If response.StatusCode = 200 Then
                strErrorRef = "Web " & strWebOrder
                strErrorReason = "Order Status Changed to Exported"
                strPutMessage = ""
                WriteError()
            Else
                strErrorRef = "Web " & strWebOrder
                strErrorReason = "Unable to change Web Order Status to Exported"
                strPutMessage = ""
                WriteError()
            End If
        Next
    Catch ex As Exception
        strErrorRef = "Web " & strWebOrder
        strErrorReason = "Unable to change Web Order Status to Exported"
        strPutMessage = (ex.ToString)
        WriteError()
    End Try
```
Susan
  • 21
  • 3

1 Answers1

0

Have you tried to increase the seconds in your executionTimeout property? If you increase it to 300, this will give your application 5 minutes to execute the command before it’s shut down, rather than the 3 minutes you’re currently using.

I’m not sure what all you’ve tried or read into, but it sounds like the code you have is taking at least 2-3 minutes to get through 2 orders, so that’s why the result you see is the same regardless of the time of day it’s being executed.

Have you tried to refactor the code to break it up a bit, for example: grab all orders with status_id 9 in one function OR store these order_ids in an array in another function elsewhere, then in a new function loop through the stored array to update the status_id?

Also, are you using webhooks at all?

Heather Barr
  • 352
  • 1
  • 8
  • The timeout settings I used I understood that they were set at the max recommended. The first two updates happen almost instantly. The timeout is only occurring on the 3rd update. In other code I get all the orders from the website that are at a certain status code. I write the order to the dto table. I am looping through the table to change the status to 9. My understanding of web hooks is limited, but from what I read on the Big Commerce documentation is they can be used to notify me if the status is changed on the site. I didn't see how it would help. Thanks. – Susan Jan 05 '21 at 16:14
  • @Susan Yeah, you could be getting a time out if the store has too many api calls. As in you're hitting api limits. This could also be related to any apps you also have running. You can go through partner portal here: https://partners.bigcommerce.com/English/ or open support ticket to get help with this hands-on. You can work with our 24/7 Technical Support team for one-on-one assistance with your store. Contact them over live chat, or give them a call anytime at any of the international toll-free numbers listed here: https://support.bigcommerce.com/s/#contact – Heather Barr Jan 08 '21 at 16:13
  • Thanks I will do that. – Susan Jan 11 '21 at 14:36
  • I'd be surprised if you were hitting the rate limit that consistently! Remember:"The store’s overall quota is distributed across all apps that are accessing the store at a given time.", and you can check how you're doing in the response headers (X-Rate-Limit-Requests-Left) – jdswift Jan 19 '21 at 08:52