← index #4801Issue #5624
Off-topic · high · value 0.761
QUERY · ISSUE

sock.connect(socket.getaddrinfo(ip,port)[0][-1]) takes too long to respond

openby hetvishah08opened 2019-05-21updated 2019-05-24

I'm trying to use usocket library in my application on ESP32 DevkitC and I want to develop a software where if I input a wrong host address it should respond quickly, reset and try again through a webserver based configuration.

sock.connect(socket.getaddrinfo(slave_ip, slave_port)[0][-1])

During testing, I intentionally input the wrong address and it takes around 19 seconds, after which it responds with this error:

[Errno 113] EHOSTUNREACH

I want to reduce this time so that i can perform some other actions.
P.S: sock.setblocking(False) is not an option.

CANDIDATE · ISSUE

ESP32: Socket.listen(backlog) leads to OSError: 112

openby mrwhy-origopened 2020-02-08updated 2020-02-11
port-esp32

Currently I'm trying to listen to a socket. My setup is utilizing uasyncio.

But the same error is happening with plain use of sockets as well.

I'm building the master branch with EspIDF 3.3.1

import usocket as _socket
ai = _socket.getaddrinfo("0.0.0.0", 80, 0, _socket.SOCK_STREAM)
ai = ai[0]
s = _socket.socket(ai[0], ai[1], ai[2])
s.setblocking(False)
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, 1)
s.bind(ai[-1])
s.listen(10)

Edit:
Just finished tests with ESP IDF 4 --> Same problem.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied