ESP8266 [Errno 103] ECONNABORTED\r\n')

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
gary
Posts: 1
Joined: Fri Mar 20, 2020 7:40 pm

ESP8266 [Errno 103] ECONNABORTED\r\n')

Post by gary » Fri Mar 20, 2020 7:51 pm

Hello,

I am having issues running the following script for a longer period of time.
It is a nodemcu esp8266

Code: Select all

#!/usr/bin/env python3

import machine
import network
from time import sleep
import urequests
import json

wifiap = network.WLAN(network.AP_IF)
wifiap.active(False)
routercon = network.WLAN(network.STA_IF)
routercon.active(True)
routercon.ifconfig(('10.0.0.128','255.255.255.0','10.0.0.138','10.0.0.138'))
routercon.connect('mywifi', '123')
while not routercon.isconnected():
    pass

posturl=('http://10.0.0.156:23102/rest/v2/send')

adc = machine.ADC(0)
gc.enable()

while True:
    value = adc.read()
    if value < 200:
       message = {'username': 'test', 'message': value, 'chatid': 'test', 'password': 'test', 'notifyself': 'false'}
       r = urequests.post(posturl, data=json.dumps(message).encode())
       r.close()
    gc.collect()
    sleep(1)
It works as expected in the beginning but after some time I get the following stacktrace:

Code: Select all

Traceback (most recent call last):
  File "/usr/local/bin/ampy", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/ampy/cli.py", line 337, in run
    output = board_files.run(local_file, not no_output)
  File "/usr/local/lib/python3.6/dist-packages/ampy/files.py", line 303, in run
    out = self._pyboard.execfile(filename)
  File "/usr/local/lib/python3.6/dist-packages/ampy/pyboard.py", line 273, in execfile
    return self.exec_(pyfile)
  File "/usr/local/lib/python3.6/dist-packages/ampy/pyboard.py", line 267, in exec_
    raise PyboardError('exception', ret, ret_err)
ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n  File "<stdin>", line 28, in <module>\r\n  File "urequests.py", line 152, in post\r\n  File "urequests.py", line 89, in request\r\nOSError: [Errno 103] ECONNABORTED\r\n')
No idea what to do.
I tried to play around with the garbage collection but it didn't help.

Any ideas?

Thanks,
BR

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: ESP8266 [Errno 103] ECONNABORTED\r\n')

Post by jimmo » Tue Apr 14, 2020 5:31 am

gary wrote:
Fri Mar 20, 2020 7:51 pm
It works as expected in the beginning but after some time I get the following stacktrace:
It's possible that the remote server you're talking to is returning an error.

Perhaps try adding a try/except around the urequests.post line so you can recover from any error and the program can continue.

Post Reply