Page 1 of 1

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

Posted: Fri Oct 11, 2019 9:44 am
by Adonai
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()

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

Posted: Fri Oct 11, 2019 10:50 am
by ghayne
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()

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

Posted: Sun Oct 13, 2019 8:29 am
by Adonai
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

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

Posted: Sun Oct 13, 2019 11:28 pm
by jimmo
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.