Having a weird problem, the where TCP "accept" is not returning. I can send UDP messages to the device, but it is not receiving a TCP connection. Wireshark shows my request is going out from my PC, but ESP32 is not responding. I get the same problem with the this https://github.com/cmmakerclub/esp32-webserver.git (i.e. no response). And I get the same problem with this code: https://github.com/nkolban/esp32-snippe ... ets/server.
I'm familiar with sockets, built many socket solutions in the past, but this one has stumped me. I tried turning on LWIP_DEBUG which provides lots of other output, but nothing to help with this unfortunately.
So I'm hoping there's some simple thing I'm missing, like a firewall setting on the ESP32 to open the TCP port or something ?
Here's my code.
https://github.com/clovett/firefly/tree ... networking
The UdpMesageStream works great. The TcpMessageStream does not work yet...
TCP not working, but UDP does work
Re: TCP not working, but UDP does work
Note that I have found it is sensitive to which router I use. I found another router that works fine. But ESP32 doesn't seem to like the TP-Link N150 Wireless 3G/4G Portable Router, at least for TCP traffic. For UDP it works great. Are there known issues in the TCP stack, or router settings/security I need to watch out for ?
(I also confirmed it is not my code, I get the same behavior using micropython with these lines of very simple socket code, this code works perfectly if I connect to a Nighthawk R7000 router, but not if I use the TP-Link N150. The socket does not connect.
import network
import socket
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('CLOVETT-YOGA-WIFI','Fly4Me2+')
sta_if.connect('BlueMountains','GeeThanks')
# wait for ip address then check if it's connected
sta_if.isconnected()
# check if it's working
print(socket.getaddrinfo("www.google.com", 80))
server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
server_sock.bind(("192.168.1.27",5102))
server_sock.listen(5)
client_sock, addr = server_sock.accept()
data = client_sock.recv(100)
# on the PC
import socket
client_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
client_sock.bind(("192.168.1.15",8002))
client_sock.connect(("192.168.1.27",5102))
client_sock.send('Hello ESP32!')
(I also confirmed it is not my code, I get the same behavior using micropython with these lines of very simple socket code, this code works perfectly if I connect to a Nighthawk R7000 router, but not if I use the TP-Link N150. The socket does not connect.
import network
import socket
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.connect('CLOVETT-YOGA-WIFI','Fly4Me2+')
sta_if.connect('BlueMountains','GeeThanks')
# wait for ip address then check if it's connected
sta_if.isconnected()
# check if it's working
print(socket.getaddrinfo("www.google.com", 80))
server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
server_sock.bind(("192.168.1.27",5102))
server_sock.listen(5)
client_sock, addr = server_sock.accept()
data = client_sock.recv(100)
# on the PC
import socket
client_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
client_sock.bind(("192.168.1.15",8002))
client_sock.connect(("192.168.1.27",5102))
client_sock.send('Hello ESP32!')
Re: TCP not working, but UDP does work
Thanks for the report. Can you use wireshark to capture traffic between the ESP32 and this special router?
Re: TCP not working, but UDP does work
Still working on that, but I found another mobile router that does work fine. So interesting that it is just a specific brand of router that the ESP32 doesn't like...
Who is online
Users browsing this forum: No registered users and 145 guests