TCP not working, but UDP does work

clovett
Posts: 3
Joined: Mon Jun 26, 2017 2:02 am

TCP not working, but UDP does work

Postby clovett » Mon Jun 26, 2017 2:12 am

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...

clovett
Posts: 3
Joined: Mon Jun 26, 2017 2:02 am

Re: TCP not working, but UDP does work

Postby clovett » Tue Jun 27, 2017 8:42 am

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!')

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: TCP not working, but UDP does work

Postby ESP_igrr » Tue Jun 27, 2017 10:48 am

Thanks for the report. Can you use wireshark to capture traffic between the ESP32 and this special router?

clovett
Posts: 3
Joined: Mon Jun 26, 2017 2:02 am

Re: TCP not working, but UDP does work

Postby clovett » Wed Jul 12, 2017 8:16 am

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 129 guests