"OSError: [Errno 103] ECONNABORTED" what to do?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Adonai
Posts: 2
Joined: Fri Oct 11, 2019 9:33 am

"OSError: [Errno 103] ECONNABORTED" what to do?

Post by Adonai » Fri Oct 11, 2019 9:44 am

Hello, I am writing code for a home weather station. Data received from sensors is sent to the site for further processing. To work, the script must automatically run after shutdown or sleep. When starting from boot.py or main.py, it generates an error "OSError: [Errno 103] ECONNABORTED". The code is working, when started manually it works fine What to do? Weather Station Code:

Code: Select all

from machine import deepsleep, I2C
import machine
import urequests
import time
import bmp180

def index():
	i2c = I2C(sda = machine.Pin(5), scl = machine.Pin(4), freq = 1000000)
	bmp = bmp180.BMP180(i2c)
	#r = float(10040 * ((1024/a.read())-1))
	#r = str((298 * 3950) / (3950 + 298 * log(r / 5000)) - 274)[0:5:1]
	urequests.get('http://192.168.100.3/input_data/?temp='+str(bmp.temperature)+'&pressure='+str(bmp.pressure)+'&vl=1')
	deepsleep(10000)
index()

User avatar
ghayne
Posts: 42
Joined: Sat Jun 08, 2019 9:31 am
Location: Cwmllynfell, Wales

Re: "OSError: [Errno 103] ECONNABORTED" what to do?

Post by ghayne » Fri Oct 11, 2019 10:50 am

I think you should be using the POST method

Code: Select all

resp = urequests.post('http://192.168.100.3/input_data/?temp='+str(bmp.temperature)+'&pressure='+str(bmp.pressure)+'&vl=1')
resp.close()

Adonai
Posts: 2
Joined: Fri Oct 11, 2019 9:33 am

Re: "OSError: [Errno 103] ECONNABORTED" what to do?

Post by Adonai » Sun Oct 13, 2019 8:29 am

No, that is not the problem. The error is in connecting to the site by ip. After replacing IP with a domain name all work

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

Re: "OSError: [Errno 103] ECONNABORTED" what to do?

Post by jimmo » Sun Oct 13, 2019 11:28 pm

ghayne is right though -- Although this is unrelated to your ECONNABORTED problem, you should never have a GET request that modifies state on the server, as GET requests are expected to be able to be re-requested, cached, retried, etc.

Assuming the IP was correct, then possibly your server is expecting a host header (i.e. virtual host). But more likely the IP was out of date and the hostname was looking up the correct address.

Post Reply