Repository navigation
OSError: [Errno 12] ENOMEM ESP32-Micropython-Azure-Event-Hub-Client #5219
Description
Activity
But I'm receiving this error (OSError: [Errno 12] ENOMEM ) on the line number 113
SSL connections take a lot of memory, and usually you can only have one open at a time.
What is the full output of the script when it runs into an error?
You should move the
s.close()line from the end of thetry:to the start of thefinally:. That should help.It prints "Messages sent: 12, errors:12 " and numbers incrementing. At start, I didn't know what is the actual error so I commented the try, extecpt and finally, so I got this error
this is the error that I'm receving

This is the actual code that I'm using# if not oledDisplay: # builtinLed.value(0) # turn on led checkwifi() newSasToken() count = count + 1 #temperature, pressure, humidity = mySensor.measure() temperature, pressure, humidity = (36, 67, 60) light = 0 freeMemory = gc.mem_free() # if oledDisplay: # display.fill(0) # display.text('t:' + str(temperature), 0, 0) # display.text('p:' + str(pressure), 0, 9) # display.text('h:' + str(humidity), 0, 18) # display.text('m:' + str(freeMemory), 0, 27) # display.text('c:' + str(count), 0, 36) # display.text('d:' + cfg.deviceId, 0, 45) # display.text('e:' + str(errorCount), 0, 53) # display.show() data = b'{"DeviceId":"%s","Id":%u,"Mem":%u,"Celsius":%s,"hPa":%s,"Humidity":%s, "Geo":"%s", "Light":%d, "Errors":%d}' % ( cfg.deviceId, count, freeMemory, temperature, pressure, humidity, cfg.location, light, errorCount) #try: s = socket.socket() s.connect(addr) s = ussl.wrap_socket(s) # SSL wrap # Send POST request to Azure IoT Hub # s.write("POST /devices/" + cfg.deviceId + # "/messages/events?api-version=2016-02-03 HTTP/1.0\r\n") s.write("POST /devices/" + cfg.deviceId +"/messages/events?api-version=2018-06-30 HTTP/1.0\r\n") #s.write("POST " + hub.endpoint + " HTTP/1.1\r\n") # HTTP Headers s.write("Host: " + cfg.host + "\r\n") s.write("Authorization: " + SAS + "\r\n") s.write("Content-Type: application/json\r\n") s.write("Connection: close\r\n") s.write("Content-Length: " + str(len(data)) + "\r\n\r\n") # Data s.write(data) # Print 128 bytes of response print(s.read(128)[:12]) s.close() #except: print('Problem posting data') errorCount = errorCount + 1 #finally: # if not oledDisplay: # builtinLed.value(1) # turn off led print('messages sent: %d, errors: %d' % (count, errorCount)) time.sleep(cfg.sampleRate)I have tried your suggestion
You should move the s.close() line from the end of the try: to the start of the finally:. That should help
But getting the same thing
I'm experiencing the same issue. Getting ENOMEM at the line
ussl.wrap_socket(s)
I'm not using Azure IOT, just making a simple HTTP get, with a tiny text file (overhttps).
Disappointing as everything these days is over HTTPS...Also seeing this error intermittantly when calling ssl.wrap_socket()
Maybe its duplicated #7038 ?
Is there any way to open just two simultaneous SSL connections? I want to keep one stream open indefinitely and also send some https requests intermittently without closing the original socket.
This issue is now being tracked in #8940.
Hi,
I'm working on a project to connect esp32 to Azure event/iot hub using gloveboxes git project.
But I'm receiving this error (OSError: [Errno 12] ENOMEM ) on the line number 113
Link to this github repository is
https://github.com/gloveboxes/ESP32-Micropython-Azure-IoT-and-Event-Hub-Client