Cannot loop traffic to internal real network interface - not using loopback
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 13.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Basic Infos
- [X] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [X] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [X] I have tested that the issue is present in current master branch (aka latest git).
- [X] I have searched the issue tracker for a similar issue.
- [X] If there is a stack dump, I have decoded it.
- [X] I have filled out all fields below.
#### Platform
- Hardware: [ESP-12]
- Core Version: 3.1.2
- Development Env: [Platformio]
- Operating System: [Windows]
### Settings in IDE
- Module: [Generic ESP8266 Module|]
- Flash Mode: [qio]
- Flash Size: [4MB]
- lwip Variant: [v2 Lower Memory]
- Reset Method: [ck|nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz|]
- Upload Using: [SERIAL]
- Upload Speed: [115200
### Problem Description
it it previously indicated that local loopback interface 127.0.0.1 is not available in lwip2 and advised against trying to use.
as documented in https://github.com/esp8266/Arduino/issues/6437
previous case suggests to use the local available real interface instead of 127.0.0.1 as loopback.
however as seen below, traffic routed to the local UDP socket is not received by the stack.
the UDP client listens to external traffic and sees traffic coming from netcat on another computer.
but not from internal stack
### [MCVE](https://stackoverflow.com/help/mcve) Sketch
```cpp
#include
#include
#include
#define WIFI_SSID "xxxxxx"
#define WIFI_PASSWORD "yyyyy"
#define SYSLOG_SERVER "lmSyslog.local"
#define SYSLOG_PORT 514
WiFiUDP udpServer, udpClient;
unsigned int received_bytes = 0;
void setup()
{
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
}
digitalWrite(LED_PIN, HIGH);
Serial.begin(9600, SERIAL_8N1);
udpServer.begin(SYSLOG_PORT);
delay(100);
};
// the loop routine runs over and over again forever:
void loop()
{
Serial.print("Sending to loopback server on local interface not loopback 127.0.0.1 ");
delay(100);
udpClient.beginPacket(WiFi.localIP(), SYSLOG_PORT);
udpClient.write("Hello, world");
udpClient.endPacket();
delay(100);
received_bytes = udpServer.parsePacket();
Serial.printf("Relay loop on %s, UDP queue size %d \n", WiFi.localIP().toString().c_str(), received_bytes);
for (int i = 0; i < received_bytes; i++)
{
char c = udpServer.read();
Serial.printf("%c", c);
}
delay(1000);
};
```
### Debug Messages
```
ing to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 17
UDP test message
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0
Sending to loopback server on local interface not loopback 127.0.0.1 Relay loop on 192.168.0.171, UDP queue size 0
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.