Exception When Performing Http Post

I am getting the following exception when i perform a post the error does not happen right away it usually takes 35 minutes give or take 20 seconds. My code checks into a server every minute if it fails it tries again after two minutes if this fails i get my device to reboot. I don’t understand why the error only occurs after the device has been running for a while.Please help.

Exception System.Exception - CLR_E_FAIL (1)

#### Message: 
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDhcp [IP: 000f] ####
#### GHI.Networking.BaseInterface::EnableDhcp [IP: 0011] ####
#### VLife.Logger.Program::Main [IP: 0044] ####

A first chance exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Net.dll

I am using a Fez Raptor with a G400 chip. It has firmware version and boot loader version as below

Loader (TinyBooter) version information:
4.3.7.7 on this computer.
4.3.6.0 on this device.

The Loader (TinyBooter) not up to date. <<<

Firmware (TinyCLR) version information:
4.3.7.10 on this computer.
4.3.7.10 on this device.

The Firmware (TinyCLR) is up to date. <<<

and the ethernet module is the ethernet ENC28 Module I am usng the the GHI SDK 2015 R1 SDK

Here is the code in question that is causing the issue i think.

    private static void CheckIn() {
        try {
            // Instantiate interface and start network
            //Eth = new EthernetENC28J60(SPI.SPI_module.SPI2, GHI.Pins.G400.PB5, GHI.Pins.G400.PB0, GHI.Pins.G400.PA7, 4000); // Socket 1
            using (var eth = new EthernetENC28J60(SPI.SPI_module.SPI1, GHI.Pins.G400.PA28, GHI.Pins.G400.PB1, GHI.Pins.G400.PC23, 4000)) {
                // Start ethernet
                eth.Open(); // Open ethernet
                eth.EnableDhcp(); // Start DHCP
                eth.EnableDynamicDns(); // Enable fetching DNS server automatically

                // Wait for DHCP to configure
                var ledState = false;
                for (var i = 0; i < DHCPTimeout / 500 && eth.IPAddress == "0.0.0.0"; i++) {
                    DebugLed.Write(ledState = !ledState);
                    Delay(500);
                }
                DebugLed.Write(false);

                // Check DHCP was successful
                if (eth.IPAddress == "0.0.0.0") {
                    CheckInFailed("DHCP timed out.");
                    return;
                }

                // Log particulars
                Log.RaiseEvent(EventLevelType.Verbose, 0, "Network started.", "IP address: " + eth.IPAddress + "/" + eth.SubnetMask + "  Gateway: " + eth.GatewayAddress + "  DNS: " + StringUtility.Join(",", eth.DnsAddresses) + "  MAC: " + eth.PhysicalAddress.ToHexString());

                // Allocate payload
                var payload = new byte[16 + 1 + Meters.Length * 4];

                // Add MAC address to payload
                Array.Copy(eth.PhysicalAddress, 0, payload, 10, 6);

                // Add flags to payload
                payload[16] = (byte)Flags;

                // Add pulses to payload
                uint pulses;
                byte[] buffer;
                Meter meter;
                var sb = new StringBuilder();
                for (byte index = 0; index < Meters.Length; index++) {
                    // Get meter
                    meter = Meters[index];

                    // Get pulses
                    pulses = meter.ExtractPulses();

                    // Convert to byte array
                    buffer = BitConverter.GetBytes(pulses);

                    // Add to payload
                    Array.Copy(buffer, 0, payload, 17 + index * 4, 4);

                    // Append to logging information
                    if (index > 0) {
                        sb.Append(", ");
                    }
                    sb.Append("[");
                    sb.Append(index);
                    sb.Append("]");
                    sb.Append(pulses);
                }

                // Show working state
                for (byte i = 0; i < 10; i++) {
                    DebugLed.Write(i % 2 == 0);
                    Delay(100);
                }

                // Make HTTP request
                using (var request = (HttpWebRequest)HttpWebRequest.Create(CheckInUrl)) {
                    // Configure request
                    request.Method = "POST";
                    request.KeepAlive = CheckInKeepAlive;
                    request.Timeout = CheckInTimeout;
                    request.ReadWriteTimeout = CheckInTimeout;
                    request.Accept = "application/octet-stream";
                    request.UserAgent = DeviceVersion;
                    request.ContentType = "application/octet-stream";
                    request.ContentLength = payload.Length;

                    // Attach payload
                    using (var requestStream = request.GetRequestStream()) {
                        requestStream.Write(payload, 0, payload.Length);
                    }

                    // Execute request
                    using (var response = request.GetResponse()) {
                        using (var stream = response.GetResponseStream()) {
                            // Set read timeout
                            stream.ReadTimeout = CheckInStreamReadTimeout;

                            // Abort if not sane
                            if (response.ContentType.ToUpper() != "APPLICATION/OCTET-STREAM") {
                                using (var reader = new StreamReader(stream)) {
                                    var body = reader.ReadToEnd();
                                    CheckInFailed(body);

                                }
                                CheckInFailed("Invalid server response. Unexpected content type '" + response.ContentType + "'.");
                                return;
                            }
                            if (stream.Length < 2) {
                                CheckInFailed("Stream too short (" + stream.Length + "b).");
                                return;
                            }

                            // Read delay value
                            var delay = stream.ReadUInt16() * 1000;

                            // Clear error flags
                            Flags = CheckInFlag.None;

                            // Reset failure delay
                            CheckInNextFailureDelay = CheckInFailureMinDelay;

                            // For each meter...
                            for (byte index = 0; index < Meters.Length; index++) {
                                // Get meter
                                meter = Meters[index];

                                // Confirm pulse extraction
                                meter.ConfirmPulseExtraction();
                            }

                            // Log
                            Log.RaiseEvent(EventLevelType.Verbose, 204, "Check-in successful.", sb.ToString() + "  Next check-in: " + delay + "ms");

                            // Show state
                            DebugLed.Write(true);

                            // Wait given delay
                            Delay(delay, DelayVarianceFactor);
                        }
                    }
                }
            }
        } catch (WebException ex) {
            var se = ex.InnerException as SocketException;
            if (null != se) {
                CheckInFailed("Socket error #" + se.ErrorCode + " occurred inside of a WebException.");
            } else {
                CheckInFailed("WebException occurred: " + ex.Message);
            }
        } catch (SocketException ex) {
            CheckInFailed("SocketException occurred: " + ex.Message);
        } catch (Exception ex) {
            CheckInFailed("Exception occurred: " + ex.Message);
            Log.RaiseEvent(EventLevelType.Informational, 0, ex.StackTrace);
            Delay(1000);
        }
    }

    private static void CheckInFailed(string message) {
        // For each meter...
        Meter meter;
        for (byte index = 0; index < Meters.Length; index++) {
            // Get meter
            meter = Meters[index];

            // Revert pulse extraction
            meter.RevertPulseExtraction();
        }

        // Add flag
        Flags |= CheckInFlag.CheckInFailed;

        // Log
        Log.RaiseEvent(EventLevelType.Error, 204, "Check-in failed. " + message + " Waiting " + CheckInNextFailureDelay + "ms before retrying.");

        if (CheckInNextFailureDelay > 120000) {
            PowerState.RebootDevice(false, 0);
        }

            
        // Show state
        DebugLed.Write(false);

        // Wait given delay
        Delay(CheckInNextFailureDelay, DelayVarianceFactor);

        // Calculate next failure delay - backing off exponentially
        CheckInNextFailureDelay = MathUtility.Min(CheckInFailureMaxDelay, CheckInNextFailureDelay * CheckInFailureExponent);
    }

Hi Shane, welcome to the forum.

First up, before digging deeper, can you update the tinybooter?

1 Like

Ok Updating now

Loader (TinyBooter) version information:
4.3.7.7 on this computer.
4.3.7.7 on this device.

The Loader (TinyBooter) is up to date. <<<

Firmware (TinyCLR) version information:
4.3.7.10 on this computer.
4.3.7.10 on this device.

The Firmware (TinyCLR) is up to date. <<<
Please wait for the device to reboot… Done.

Will now run my software and see if the same error occors

Updating the bootloader did not make a difference. like clockwork after 32 checkin’s the network adapter fails. Every 32nd checkin gives the following error

#### Exception System.Exception - CLR_E_FAIL (1) ####
#### Message: 
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration [IP: 0000] ####
#### Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDhcp [IP: 000f] ####
#### GHI.Networking.BaseInterface::EnableDhcp [IP: 0011] ####
#### VLife.Logger.Program::Main [IP: 0044] ####

A first chance exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Net.dll
00:34:36 [2#204] Check-in failed. Exception occurred: Exception was thrown: System.Exception Waiting 16000ms before retrying.
00:34:52 [4#0] Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::UpdateConfiguration
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface::EnableDhcp
GHI.Networking.BaseInterface::EnableDhcp
VLife.Logger.Program::Main

Changed my delay to 3 seconds between checkin attempts and after 31 attempts the 32nd attempt fails.

I can’t tell you why it is happening without debugging (and UpdateConfiguration is native code), but maybe you can avoid the problem.

EnableDHCP() appears to be a ‘sticky’ configuration property - that is, it is persisted in the Flash config block. You only need to do it once. Add a flag to your code that ensures that you only call EnableDHCP on your first trip through the loop.

I have not tested this - this is from inspecting the code, but it looks like the .Open() should use the last network config, meaning that you only need to enable DHCP once. Others with more experience may be able to contradict me based on real experience.

Ref : netmf-interpreter/NetworkInterface.cs at 34a92c3d79d3d1c48440dc32f88d5b81095311a4 · NETMF/netmf-interpreter · GitHub

It appears that the issue is related to resetting the network adapter. If i don’t recreate the network connection after each checkin the device will work fine for a time.

I changed my code so that it no longer recreates the network connection everytime it does a checkin and only resets the network adapter when there is a network exception however i suspect that after this has happened 31 times the entire device will need to be rebooted to recover from the exception.

@ mcalsyn - Ok will try this thanks

@ Shane Edwards - Ok made it so the dhcp is only enabled once at the beginning of the loop same problem after 31 checkins the network adapter stops responding but no exception this time it just stops responding.

@ mcalsyn thanks tho :slight_smile:

Well, that’s a sorta/kinda success. What does the stack trace look like (for each thread) when you hit Pause in the debugger? That is, where is it stopped?

@ mcalsyn - Hmm i am not a native to .net came over from arduino will research what you mean by “stack Trace” then get back to you.

The underling error is in the library though not my fault as far as i can tell. I think the guys at GHI need to fix this.

If we show that there is an error in a GHI library, I am sure they will fix it, but I think we’re a long, long way from demonstrating that. Just because there isn’t an exception in your code doesn’t mean that there’s a bug in GHI or Microsoft code. We need to examine exactly what it is doing when it hangs.

In Visual Studio, after it hangs, hit the pause button. Then you should have a Call Stack window at the bottom of your screen. You can also use Debug->Windows->Threads to view the call stack for other threads (sometimes necessary if your Pause occurred while executing in some thread you don’t actually care about).

Ok Have done a work around for now so the network adapter is only reset if there is an exception instead of everytime the device needs to checkin. This should mean we can have 32 exceptions (that are not the one on the first page of this post)before the device needs to be rebooted. Then i have made the entire device reboot itself when we have rebooted the network adapter 32 times this should mean we could run for upto a week without needing a reboot depending on how many network exceptions we get per day. I need to leave my device to run for a few days now to see if it locks up because GHI apparently fixed the watchdog as well as other things in the latest firmware and SDK update 2015 r1 . I need to see if in fact this is the case. Another interesting point is that 32 tries is the same as 5bits or 11111 so i feel it is not a coincidence that it fails after 32 times. This must have something to do with some buffer or something that regulates the number of instances of the network. I think @ mcalsyn you made an interesting point when you said i only need to enable the DHCP once. this was correct. So i will get back to you in a few days after i have seen how stable the device is for now.

@ mcalsyn Ok it is stable the way i wrote it now have done what you asked and opened the call stack now what

Ok so thought i would completely disable dhcp and make the ip static. Works for one checkin then breaks

00:00:25 [4#0] Initializing…
00:00:25 [4#0] Starting watchdog…
00:00:25 [4#0] Starting network…
00:00:26 [5#0] Network ready. (IP address: 192.168.0.199/255.255.255.0 Gateway: 192.168.0.1 DNS: 61.9.211.33,61.9.211.1 MAC: CEA27011E67)
00:00:26 [4#0] Starting meter interface…
00:00:26 [5#0] Meter interfaces ready. ([0]=32, [1]=7, [2]=8, [3]=37, [4]=22, [5]=21, [6]=23)
00:00:26 [4#0] Ready.
00:00:26 [5#0] Network ready. (IP address: 192.168.0.199/255.255.255.0 Gateway: 192.168.0.1 DNS: 61.9.211.33,61.9.211.1 MAC: CEA27011E67)
00:00:28 [5#204] Check-in successful. ([0]0, [1]0, [2]0, [3]0, [4]0, [5]0, [6]0 Next check-in: 3000ms)
GC: 1msec 330684 bytes used, 66775080 bytes available
Type 0F (STRING ): 1020 bytes
Type 11 (CLASS ): 10392 bytes
Type 12 (VALUETYPE ): 552 bytes
Type 13 (SZARRAY ): 3060 bytes
Type 01 (BOOLEAN ): 24 bytes
Type 03 (U1 ): 192 bytes
Type 04 (CHAR ): 600 bytes
Type 07 (I4 ): 36 bytes
Type 0F (STRING ): 24 bytes
Type 11 (CLASS ): 2100 bytes
Type 12 (VALUETYPE ): 84 bytes
Type 15 (FREEBLOCK ): 66775080 bytes
Type 16 (CACHEDBLOCK ): 276 bytes
Type 17 (ASSEMBLY ): 34500 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 192 bytes
Type 1B (DELEGATE_HEAD ): 612 bytes
Type 1D (OBJECT_TO_EVENT ): 360 bytes
Type 1E (BINARY_BLOB_HEAD ): 273948 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 408 bytes
Type 22 (TIMER_HEAD ): 72 bytes
Type 27 (FINALIZER_HEAD ): 384 bytes
Type 31 (IO_PORT ): 504 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 3420 bytes
GC: performing heap compaction…
00:00:31 [5#0] Network ready. (IP address: 192.168.0.199/255.255.255.0 Gateway: 192.168.0.1 DNS: 61.9.211.33,61.9.211.1 MAC: CEA27011E67)
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::connect [IP: 0000] ####
#### System.Net.Sockets.Socket::Connect [IP: 001d] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
#### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
#### VLife.Logger.Program::Main [IP: 0054] ####
#### SocketException ErrorCode = 10065
#### SocketException ErrorCode = 10065
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10065
#### SocketException ErrorCode = 10065
#### Exception System.Net.WebException - 0x00000000 (1) ####
#### Message: connection failed
#### System.Net.HttpWebRequest::EstablishConnection [IP: 0172] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
#### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
#### VLife.Logger.Program::Main [IP: 0054] ####
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
00:00:33 [2#204] Check-in failed. Socket error #10065 occurred inside of a WebException. Waiting 16000ms before retrying.
00:00:33 [5#0] Network ready. (IP address: 192.168.0.199/255.255.255.0 Gateway: 192.168.0.1 DNS: 61.9.211.33,61.9.211.1 MAC: CEA27011E67)
GC: 1msec 330624 bytes used, 66775140 bytes available
Type 0F (STRING ): 1020 bytes
Type 11 (CLASS ): 10464 bytes
Type 12 (VALUETYPE ): 552 bytes
Type 13 (SZARRAY ): 3060 bytes
Type 01 (BOOLEAN ): 24 bytes
Type 03 (U1 ): 192 bytes
Type 04 (CHAR ): 600 bytes
Type 07 (I4 ): 36 bytes
Type 0F (STRING ): 24 bytes
Type 11 (CLASS ): 2100 bytes
Type 12 (VALUETYPE ): 84 bytes
Type 15 (FREEBLOCK ): 66775140 bytes
Type 16 (CACHEDBLOCK ): 120 bytes
Type 17 (ASSEMBLY ): 34500 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 192 bytes
Type 1B (DELEGATE_HEAD ): 612 bytes
Type 1D (OBJECT_TO_EVENT ): 360 bytes
Type 1E (BINARY_BLOB_HEAD ): 273948 bytes
Type 1F (THREAD ): 768 bytes
Type 20 (SUBTHREAD ): 96 bytes
Type 21 (STACK_FRAME ): 408 bytes
Type 22 (TIMER_HEAD ): 72 bytes
Type 27 (FINALIZER_HEAD ): 408 bytes
Type 31 (IO_PORT ): 504 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 3420 bytes
GC: performing heap compaction…
00:00:49 [5#0] Network ready. (IP address: 192.168.0.199/255.255.255.0 Gateway: 192.168.0.1 DNS: 61.9.211.33,61.9.211.1 MAC: CEA27011E67)
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::connect [IP: 0000] ####
#### System.Net.Sockets.Socket::Connect [IP: 001d] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
#### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
#### VLife.Logger.Program::Main [IP: 0054] ####
#### SocketException ErrorCode = 10065
#### SocketException ErrorCode = 10065
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10065
#### SocketException ErrorCode = 10065
#### Exception System.Net.WebException - 0x00000000 (1) ####
#### Message: connection failed
#### System.Net.HttpWebRequest::EstablishConnection [IP: 0172] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
#### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
#### VLife.Logger.Program::Main [IP: 0054] ####
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
00:00:50 [2#204] Check-in failed. Socket error #10065 occurred inside of a WebException. Waiting 32000ms before retrying.
00:00:51 [5#0] Network ready. (IP address: 192.168.0.199/255.255.255.0 Gateway: 192.168.0.1 DNS: 61.9.211.33,61.9.211.1 MAC: CEA27011E67)
00:01:07 [6#203] Pulse from meter #2
00:01:07 [6#203] Pulse from meter #4
00:01:07 [6#203] Pulse from meter #3
GC: 1msec 331140 bytes used, 66774624 bytes available
Type 0F (STRING ): 1020 bytes
Type 11 (CLASS ): 10464 bytes
Type 12 (VALUETYPE ): 552 bytes
Type 13 (SZARRAY ): 3060 bytes
Type 01 (BOOLEAN ): 24 bytes
Type 03 (U1 ): 192 bytes
Type 04 (CHAR ): 600 bytes
Type 07 (I4 ): 36 bytes
Type 0F (STRING ): 24 bytes
Type 11 (CLASS ): 2100 bytes
Type 12 (VALUETYPE ): 84 bytes
Type 15 (FREEBLOCK ): 66774624 bytes
Type 16 (CACHEDBLOCK ): 168 bytes
Type 17 (ASSEMBLY ): 34500 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 192 bytes
Type 1B (DELEGATE_HEAD ): 612 bytes
Type 1D (OBJECT_TO_EVENT ): 360 bytes
Type 1E (BINARY_BLOB_HEAD ): 273984 bytes
Type 1F (THREAD ): 1152 bytes
Type 20 (SUBTHREAD ): 144 bytes
Type 21 (STACK_FRAME ): 408 bytes
Type 22 (TIMER_HEAD ): 72 bytes
Type 27 (FINALIZER_HEAD ): 408 bytes
Type 31 (IO_PORT ): 504 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 3420 bytes
GC: performing heap compaction…
00:01:22 [5#0] Network ready. (IP address: 192.168.0.199/255.255.255.0 Gateway: 192.168.0.1 DNS: 61.9.211.33,61.9.211.1 MAC: CEA27011E67)
#### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (1) ####
#### Message:
#### Microsoft.SPOT.Net.SocketNative::connect [IP: 0000] ####
#### System.Net.Sockets.Socket::Connect [IP: 001d] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
#### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
#### VLife.Logger.Program::Main [IP: 0054] ####
#### SocketException ErrorCode = 10065
#### SocketException ErrorCode = 10065
A first chance exception of type ‘System.Net.Sockets.SocketException’ occurred in Microsoft.SPOT.Net.dll
#### SocketException ErrorCode = 10065
#### SocketException ErrorCode = 10065
#### Exception System.Net.WebException - 0x00000000 (1) ####
#### Message: connection failed
#### System.Net.HttpWebRequest::EstablishConnection [IP: 0172] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
#### System.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
#### VLife.Logger.Program::Main [IP: 0054] ####
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
A first chance exception of type ‘System.Net.WebException’ occurred in System.Http.dll
00:01:23 [2#204] Check-in failed. Socket error #10065 occurred inside of a WebException. Waiting 64000ms before retrying.
00:01:23 [5#0] Network ready. (IP address: 192.168.0.199/255.255.255.0 Gateway: 192.168.0.1 DNS: 61.9.211.33,61.9.211.1 MAC: CEA27011E67)
The program ‘[7] Micro Framework application: Managed’ has exited with code 0 (0x0).

It is failing on the connect. Are you sure that there isn’t a problem with the server you are connecting to or the intervening network? What does wireshark say? That is, did the TCP connection attempt ever happen or did it fail during the connect negotiation? (note that wireshark will only see traffic if it is running on the server machine, or if the machine running wireshark is connected to a hub or a switch with port replication for the port that one of the devices is connected to)

I realize this is all frustrating, but it’s hard to diagnose and give better answers when we have only part of the involved code. I have a number of devices that are posting away non-stop, so I don’t think there’s a fundamental problem with the firmware here. We just haven’t found the culprit here yet.

If you cannot get anywhere with wireshark, consider publishing the smallest possible code fragment that demonstrates the problem, and describe the server on the other end of the conversation so that we can properly replicate your issue.

“it’s your code”. attributed to Confucius.

There’s some older code examples around that performed repeated POSTs (see the network shootout https://www.ghielectronics.com/community/codeshare/entry/866) that might help.

The memory you have is shrinking each time the GC displays memory usage, which is a good sign that there’ll be a structural challenge that will possibly need a lot larger block of code to review to fully understand it