<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Debugging HTTP requests]]></title><description><![CDATA[<p dir="auto">I've been trying to make a simple HTTP request with my Atom Matrix.<br />
I want to implement:</p>
<p dir="auto"><em>A <strong>single Button Click</strong> sends a <strong>HTTP request</strong> and shows me the success or error state via the Matrix LEDs</em></p>
<p dir="auto">But my problem is that the request seems to fail consistently and I couldn't print any information about the actual request. It seems as if it fails before or while executing the request. I was able to print the exception thrown: <code>[Errno 12] ENOMEM</code><br />
Which looks like the Atom ran out of memory. But I'm confused why? The whole code snippet is already pretty small and barely does anything.</p>
<pre><code>from m5stack import *
from m5ui import *
from uiflow import *
import wifiCfg
import urequests


gc.collect()
rgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])

def buttonA_wasPressed():
  # global params
  wifiCfg.autoConnect(lcdShow=False)
  if wifiCfg.wlan_sta.isconnected():
    try:
      print(urequests.request)
      req = urequests.request(method='GET', url='https://dummyjson.com/products/1', headers={})
      print(req.text)
      print("stuff never get executed")
     
      # Show some green lights indicating success state
      rgb.set_screen([0x03ff33,0,0,0,0,0x03ff33,0,0,0x00ff33,0,0,0x03ff33,0x00bd26,0x00ff33,0,0,0x03ff33,0x00ff33,0x00ff33,0x03ff33,0,0,0x03ff33,0x03ff33,0x03ff33])
      gc.collect()
      req.close()
    except Exception as e:
      print('Failed')
      print(str(e))
      # Show some red lights indicating error state
      rgb.set_screen([0,0,0,0,0,0,0,0,0xff0000,0,0,0xff0000,0x9e0000,0xff0000,0,0,0xff0000,0xff0000,0xff0000,0xff0000,0,0,0xff0000,0xff0000,0xff0000])
  pass
btnA.wasPressed(buttonA_wasPressed)
</code></pre>
<p dir="auto">This is the log after pushing the button on my Atom Matrix</p>
<pre><code>&lt;function request at 0x3ffe7220&gt;
Failed
[Errno 12] ENOMEM
</code></pre>
<p dir="auto"><code>&lt;function request at 0x3ffe7220&gt;</code> proves that (some) request function is loaded<br />
<code>[Errno 12] ENOMEM</code> is the exception printed in the except block</p>
<p dir="auto">The Issue is clearly related to the request because if I remove the request, the success case is executed (green light etc.)</p>
<pre><code>...
 try:
      print(urequests.request)
      #req = urequests.request(method='GET', url='https://dummyjson.com/products/1', headers={})
      #print(req.text)
      print("stuff never get executed")
     
      # Show some green lights indicating success state
      rgb.set_screen([0x03ff33,0,0,0,0,0x03ff33,0,0,0x00ff33,0,0,0x03ff33,0x00bd26,0x00ff33,0,0,0x03ff33,0x00ff33,0x00ff33,0x03ff33,0,0,0x03ff33,0x03ff33,0x03ff33])
      gc.collect()
      #req.close()
...
</code></pre>
<p dir="auto">Context:</p>
<ul>
<li>I flashed the device with <a href="https://share.cleanshot.com/jj225B9w" target="_blank" rel="noopener noreferrer nofollow ugc">UIFlow_Matrix</a> v1.12.9 (latest)</li>
<li>I'm using <a href="https://share.cleanshot.com/WF03NVtK" target="_blank" rel="noopener noreferrer nofollow ugc">Arduino Lab for Micropython</a> to upload and execute code on the Atom Matrix because I found it to be the most reliable connection over USB and giving me a fast response through the console.</li>
</ul>
]]></description><link>https://community.m5stack.com/topic/5913/debugging-http-requests</link><generator>RSS for Node</generator><lastBuildDate>Sat, 16 May 2026 21:55:48 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5913.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 23 Dec 2023 12:48:04 GMT</pubDate><ttl>60</ttl></channel></rss>