WebSockets_Generic Library.

HI @shawn

I opened an issue in the library as QNEthernet and NativeEthernet staticIP not working with WS Server #39

Please check there for more detailed debug terminal output

Basically


1. DHCP is working OK with QNEthernet

Code:
Starting Teensy41_Client on TEENSY 4.1 using QNEthernet
WebSockets2_Generic v1.10.1
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using DHCP => Connected! IP address:192.168.2.107
[WS] WebsocketsClient::doestStartsWith: str = ws://192.168.2.30:8080
[WS] WebsocketsClient::doestStartsWith: prefix = ws://
[WS] WebsocketsClient::connect: step 1
[WS] WebsocketsClient::generateHandshake: base64Authorization = 
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: 192.168.2.30
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic 
Origin: https://github.com/khoih-prog/Websockets2_Generic

[WS] WebsocketsClient::connect: base64Authorization = 
[WS] WebsocketsClient::connect: step 2
[WS] WebsocketsClient::connect: step 3
[WS] WebsocketsClient::connect: step 4
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols

[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[WS] WebsocketsClient::connect: step 5
[WS] WebsocketsClient::connect: step 6
[WS] WebsocketsClient::generateHandshake: key = Upgrade
[WS] WebsocketsClient::generateHandshake: value = websocket
[WS] WebsocketsClient::generateHandshake: key = Connection
[WS] WebsocketsClient::generateHandshake: value = Upgrade
[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept
[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=
[WS] WebsocketsClient::generateHandshake: key = Origin
[WS] WebsocketsClient::generateHandshake: value = https://github.com/khoih-prog/Websockets2_Generic
[WS] WebsocketsClient::connect: step 7
Connected to server : ws://192.168.2.30:8080
Got Message: Hello Server

2. Static IP is not working OK with QNEthernet

Code:
Starting Teensy41_Client on TEENSY 4.1 using QNEthernet
WebSockets2_Generic v1.10.1
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using static IP => Connected! IP address:192.168.2.222
[WS] WebsocketsClient::doestStartsWith: str = ws://192.168.2.30:8080
[WS] WebsocketsClient::doestStartsWith: prefix = ws://
[WS] WebsocketsClient::connect: step 1
[WS] WebsocketsClient::connect: not _connectionOpen, host = 192.168.2.30 , port = 8080
Couldn't connect to server : ws://192.168.2.30:8080
 
What are you setting the netmask and gateway to? Also, what are these values when using DHCP?
 
They are set according to my local network, and they are certainly correct as they are OK for `staticIP + hostname`

https://github.com/khoih-prog/QNEthernet/blob/master/examples/WebClient/WebClient.ino#L28-L34
https://github.com/khoih-prog/QNEthernet/blob/master/examples/WebClient/WebClient.ino#L54-L63

Code:
#if !USING_DHCP
  // Set the static IP address to use if the DHCP fails to assign
  IPAddress myIP(192, 168, 2, 222);
  IPAddress myNetmask(255, 255, 255, 0);
  IPAddress myGW(192, 168, 2, 1);
  IPAddress mydnsServer(8, 8, 8, 8);
#endif

...

#if USING_DHCP
  // Start the Ethernet connection, using DHCP
  Serial.print("Initialize Ethernet using DHCP => ");
  Ethernet.begin();
#else   
  // Start the Ethernet connection, using static IP
  Serial.print("Initialize Ethernet using static IP => ");
  Ethernet.begin(myIP, myNetmask, myGW);
  Ethernet.setDNSServerIP(mydnsServer);
#endif
 
I think I figured it out; there appear to be two factors:

1. The "route error" (ERR_RTE=-4) is because the link isn't yet detected to be up when a connection is attempted. To solve this, after setting a static IP, you can call a new `Ethernet.waitForLink(timeout)` function that waits for the link to be detected. Alternatively, you can check if there's a link each time you attempt to connect as a client. I don't have a preference for either of the two approaches; it will depend on how the code is structured or intended to be used.

2. It's possible that the default connection timeout, 1000ms, isn't long enough. Try setting this higher. See: https://www.arduino.cc/en/Reference/EthernetClientSetConnectionTimeout

Note: There is an immediately valid local IP address when setting a static IP. This means that `Ethernet.waitForLocalIP(timeout)` will return true without necessarily there first being a link.
 
Last edited:
OMG, you're right.

If I change https://github.com/khoih-prog/QNEthernet/blob/master/examples/WebClient/WebClient.ino#L87 from

Code:
delay(1000);

to

Code:
#if USING_DHCP
  delay(1000);
#else  
  delay(2000);
#endif

then it's OK with `staticIP + serverIP`

Code:
Starting WebClient using QNEthernet Library
Initialize Ethernet using static IP => IP Address = 192.168.2.222
ipaddr = 3724716224
Connecting to 74.6.143.25...
QNEthernetClient::connect(IPAddress): ip = 74.6.143.25, port = 80
QNEthernetClient::connect(IPAddress): ipaddr = 74.6.143.25
QNEthernetClient::connect(ip_addr_t): enter
QNEthernetClient::connect(ip_addr_t): ip_addr_t = 74.6.143.25
ConnectionManager::connect(ip_addr_t): ipaddr = 74.6.143.25, port = 80
ConnectionManager::connect(ip_addr_t): OK tcp_new
ConnectionManager::connect(ip_addr_t): OK tcp_bind
ConnectionManager::connect(ip_addr_t): pcb->local_ip = 0.0.0.0
ConnectionManager::connect(ip_addr_t): error tcp_connect, tcp_connect() = 0
ConnectionManager::connect(ip_addr_t): OK tcp_connect
ConnectionManager::connect(ip_addr_t): OK, pcb->local_ip = 192.168.2.222
QNEthernetClient::connect(ip_addr_t): OK
Connected to 74.6.143.25
HTTP/1.1 404 Not Found on Accelerator
Date: Mon, 14 Mar 2022 18:09:29 GMT
Connection: close
Server: ATS
Cache-Control: no-store
Content-Type: text/html
Content-Language: en
X-Frame-Options: SAMEORIGIN
Content-Length: 4792
...
Disconnecting.
Received 5025 bytes in 0.2518, rate = 19.95 kbytes/second
 
Now the WebSockets is working OK with the added `delay()`, using staticIP

Just add after Ethernet.waitForLocalIP(5000)

Code:
// give the Ethernet shield a second to initialize:
#if USING_DHCP
  delay(1000);
#else  
  delay(2000);
#endif

Code:
Starting Teensy41_Client on TEENSY 4.1 using QNEthernet
WebSockets2_Generic v1.10.1
=========== USE_QN_ETHERNET ===========
Initialize Ethernet using static IP => Connected! IP address:192.168.2.222
[WS] WebsocketsClient::doestStartsWith: str = ws://192.168.2.30:8080
[WS] WebsocketsClient::doestStartsWith: prefix = ws://
[WS] WebsocketsClient::connect: step 1
[WS] QNEthernet::connect: ip = 192.168.2.30 , port =  8080
[WS] WebsocketsClient::generateHandshake: base64Authorization = 
[WS] WebsocketsClient::generateHandshake: handshake = GET / HTTP/1.1
Host: 192.168.2.30
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
User-Agent: TinyWebsockets Client
Authorization: Basic 
Origin: [url]https://github.com/khoih-prog/Websockets2_Generic[/url]


[WS] WebsocketsClient::connect: base64Authorization = 
[WS] WebsocketsClient::connect: step 2
[WS] WebsocketsClient::connect: step 3
[WS] WebsocketsClient::connect: step 4
[WS] WebsocketsClient::doestStartsWith: str = HTTP/1.1 101 Switching Protocols

[WS] WebsocketsClient::doestStartsWith: prefix = HTTP/1.1 101
[WS] WebsocketsClient::connect: step 5
[WS] WebsocketsClient::connect: step 6
[WS] WebsocketsClient::generateHandshake: key = Upgrade
[WS] WebsocketsClient::generateHandshake: value = websocket
[WS] WebsocketsClient::generateHandshake: key = Connection
[WS] WebsocketsClient::generateHandshake: value = Upgrade
[WS] WebsocketsClient::generateHandshake: key = Sec-WebSocket-Accept
[WS] WebsocketsClient::generateHandshake: value = BACScCJPNqyz+UBoqMH89VmURoA=
[WS] WebsocketsClient::generateHandshake: key = Origin
[WS] WebsocketsClient::generateHandshake: value = [url]https://github.com/khoih-prog/Websockets2_Generic[/url]
[WS] WebsocketsClient::connect: step 7
Connected to server : ws://192.168.2.30:8080
Got Message: Hello Server
 
Last edited:
What do you think of this instead:
Code:
// Give Ethernet some time to initialize
#if USING_DHCP
  if (!Ethernet.waitForLocalIP(10000)) {
    // do stuff
  } else {
    // do other stuff
  }
#else
  if (!Ethernet.waitForLink(2000)) {
    // do stuff
  } else {
    // do other stuff
  }
#endif
 
The new WebSockets2_Generic releases v1.10.2 has been published to address the staticIP + serverIP issue


Release v1.10.2

1. Fix bug when using `QNEthernet` staticIP. Check QNEthernet and NativeEthernet staticIP not working with WS Server #39
2. Add staticIP option to `NativeEthernet` examples
2. Update `Packages' Patches`

When will SSL support be added to the Teensy 4.1, I'm seeing // SSL not working here yet.

I'm currently looking to migrate an application built in python to Teensy but requires the SSL websocket client and JSON encoding.

Any advice?
 
I have 2 questions:
how can I connect to the websocket server from Windows?
how can I add an address to the ip (ie. I want to connect to ws://192.168.1.177:5557/data)?
 
I tried to compile and run the NativeEthernet example in platformio and get these errors:
Code:
Building in release mode
Linking .pio\build\teensy41\firmware.elf
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::begin(unsigned char*, unsigned long, unsigned long)':
NativeEthernet.cpp:(.text._ZN13EthernetClass5beginEPhmm+0x0): multiple definition of `EthernetClass::begin(unsigned char*, unsigned long, unsigned long)'       
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass5beginEPhmm+0x0): first defined here
c:/users/cytro/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::begin(unsigned char*, IPAddress, IPAddress, IPAddress, IPAddress)':
NativeEthernet.cpp:(.text._ZN13EthernetClass5beginEPh9IPAddressS1_S1_S1_+0x0): multiple definition of `EthernetClass::begin(unsigned char*, IPAddress, IPAddress, IPAddress, IPAddress)'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass5beginEPh9IPAddressS1_S1_S1_+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::begin(unsigned char*, IPAddress, IPAddress, IPAddress)':      
NativeEthernet.cpp:(.text._ZN13EthernetClass5beginEPh9IPAddressS1_S1_+0x0): multiple definition of `EthernetClass::begin(unsigned char*, IPAddress, IPAddress, IPAddress)'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass5beginEPh9IPAddressS1_S1_+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::begin(unsigned char*, IPAddress, IPAddress)':
NativeEthernet.cpp:(.text._ZN13EthernetClass5beginEPh9IPAddressS1_+0x0): multiple definition of `EthernetClass::begin(unsigned char*, IPAddress, IPAddress)'    
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass5beginEPh9IPAddressS1_+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::begin(unsigned char*, IPAddress)':
NativeEthernet.cpp:(.text._ZN13EthernetClass5beginEPh9IPAddress+0x0): multiple definition of `EthernetClass::begin(unsigned char*, IPAddress)'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass5beginEPh9IPAddress+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::linkStatus()':
NativeEthernet.cpp:(.text._ZN13EthernetClass10linkStatusEv+0x0): multiple definition of `EthernetClass::linkStatus()'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass10linkStatusEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::hardwareStatus()':
NativeEthernet.cpp:(.text._ZN13EthernetClass14hardwareStatusEv+0x0): multiple definition of `EthernetClass::hardwareStatus()'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass14hardwareStatusEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::maintain()':
NativeEthernet.cpp:(.text._ZN13EthernetClass8maintainEv+0x0): multiple definition of `EthernetClass::maintain()'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass8maintainEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::MACAddress(unsigned char*)':
NativeEthernet.cpp:(.text._ZN13EthernetClass10MACAddressEPh+0x0): multiple definition of `EthernetClass::MACAddress(unsigned char*)'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass10MACAddressEPh+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::localIP()':
NativeEthernet.cpp:(.text._ZN13EthernetClass7localIPEv+0x0): multiple definition of `EthernetClass::localIP()'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass7localIPEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::subnetMask()':
NativeEthernet.cpp:(.text._ZN13EthernetClass10subnetMaskEv+0x0): multiple definition of `EthernetClass::subnetMask()'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass10subnetMaskEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::gatewayIP()':
NativeEthernet.cpp:(.text._ZN13EthernetClass9gatewayIPEv+0x0): multiple definition of `EthernetClass::gatewayIP()'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass9gatewayIPEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::setMACAddress(unsigned char const*)':
NativeEthernet.cpp:(.text._ZN13EthernetClass13setMACAddressEPKh+0x0): multiple definition of `EthernetClass::setMACAddress(unsigned char const*)'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass13setMACAddressEPKh+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::setLocalIP(IPAddress)':
NativeEthernet.cpp:(.text._ZN13EthernetClass10setLocalIPE9IPAddress+0x0): multiple definition of `EthernetClass::setLocalIP(IPAddress)'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass10setLocalIPE9IPAddress+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::setSubnetMask(IPAddress)':
NativeEthernet.cpp:(.text._ZN13EthernetClass13setSubnetMaskE9IPAddress+0x0): multiple definition of `EthernetClass::setSubnetMask(IPAddress)'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass13setSubnetMaskE9IPAddress+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::setGatewayIP(IPAddress)':
NativeEthernet.cpp:(.text._ZN13EthernetClass12setGatewayIPE9IPAddress+0x0): multiple definition of `EthernetClass::setGatewayIP(IPAddress)'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass12setGatewayIPE9IPAddress+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::setRetransmissionTimeout(unsigned short)':
NativeEthernet.cpp:(.text._ZN13EthernetClass24setRetransmissionTimeoutEt+0x0): multiple definition of `EthernetClass::setRetransmissionTimeout(unsigned short)' 
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass24setRetransmissionTimeoutEt+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o): In function `EthernetClass::setRetransmissionCount(unsigned char)':
NativeEthernet.cpp:(.text._ZN13EthernetClass22setRetransmissionCountEh+0x0): multiple definition of `EthernetClass::setRetransmissionCount(unsigned char)'      
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):Ethernet.cpp:(.text._ZN13EthernetClass22setRetransmissionCountEh+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o):(.bss.Ethernet+0x0): multiple definition of `Ethernet'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):(.bss.Ethernet+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernet.cpp.o):(.bss._ZN13EthernetClass17_dnsServerAddressE+0x0): multiple definition of `EthernetClass::_dnsServerAddress'
.pio\build\teensy41\libaad\libEthernet.a(Ethernet.cpp.o):(.bss._ZN13EthernetClass17_dnsServerAddressE+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernetServer.cpp.o): In function `EthernetServer::write(unsigned char)':
NativeEthernetServer.cpp:(.text._ZN14EthernetServer5writeEh+0x0): multiple definition of `EthernetServer::write(unsigned char)'
.pio\build\teensy41\libaad\libEthernet.a(EthernetServer.cpp.o):EthernetServer.cpp:(.text._ZN14EthernetServer5writeEh+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernetServer.cpp.o): In function `EthernetServer::operator bool()':
NativeEthernetServer.cpp:(.text._ZN14EthernetServercvbEv+0x0): multiple definition of `EthernetServer::operator bool()'
.pio\build\teensy41\libaad\libEthernet.a(EthernetServer.cpp.o):EthernetServer.cpp:(.text._ZN14EthernetServercvbEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernetServer.cpp.o): In function `EthernetServer::begin()':
NativeEthernetServer.cpp:(.text._ZN14EthernetServer5beginEv+0x0): multiple definition of `EthernetServer::begin()'
.pio\build\teensy41\libaad\libEthernet.a(EthernetServer.cpp.o):EthernetServer.cpp:(.text._ZN14EthernetServer5beginEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernetServer.cpp.o): In function `EthernetServer::available()':
NativeEthernetServer.cpp:(.text._ZN14EthernetServer9availableEv+0x0): multiple definition of `EthernetServer::available()'
.pio\build\teensy41\libaad\libEthernet.a(EthernetServer.cpp.o):EthernetServer.cpp:(.text._ZN14EthernetServer9availableEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernetServer.cpp.o): In function `EthernetServer::write(unsigned char const*, unsigned int)':
NativeEthernetServer.cpp:(.text._ZN14EthernetServer5writeEPKhj+0x0): multiple definition of `EthernetServer::write(unsigned char const*, unsigned int)'
.pio\build\teensy41\libaad\libEthernet.a(EthernetServer.cpp.o):EthernetServer.cpp:(.text._ZN14EthernetServer5writeEPKhj+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernetServer.cpp.o): In function `EthernetServer::accept()':
NativeEthernetServer.cpp:(.text._ZN14EthernetServer6acceptEv+0x0): multiple definition of `EthernetServer::accept()'
.pio\build\teensy41\libaad\libEthernet.a(EthernetServer.cpp.o):EthernetServer.cpp:(.text._ZN14EthernetServer6acceptEv+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernetServer.cpp.o):(.rodata._ZTV14EthernetServer+0x0): multiple definition of `vtable for EthernetServer'
.pio\build\teensy41\libaad\libEthernet.a(EthernetServer.cpp.o):(.rodata._ZTV14EthernetServer+0x0): first defined here
.pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernetServer.cpp.o):(.bss._ZN14EthernetServer11server_portE+0x0): multiple definition of `EthernetServer::server_port'
.pio\build\teensy41\libaad\libEthernet.a(EthernetServer.cpp.o):(.bss._ZN14EthernetServer11server_portE+0x0): first defined here
c:/users/cytro/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: Warning: size of symbol `_ZN14EthernetServer11server_portE' changed from 16 in .pio\build\teensy41\libaad\libEthernet.a(EthernetServer.cpp.o) to 4 in .pio\build\teensy41\lib7d5\libNativeEthernet.a(NativeEthernetServer.cpp.o)
What an I missing?
 
Thanks, switching to QNEthernet works (still getting those warnings )
Code:
[{
	"resource": "/c:/Users/cytro/OneDrive/Documents/PlatformIO/Projects/WSServer/include/Tiny_Websockets_Generic/client.hpp",
	"owner": "cpp",
	"severity": 4,
	"message": "#warning WEBSOCKETS_USE_ETHERNET and USE_QN_ETHERNET in client.hpp [-Wcpp]",
	"startLineNumber": 58,
	"startColumn": 6,
	"endLineNumber": 58,
	"endColumn": 6
},{
	"resource": "/c:/Users/cytro/OneDrive/Documents/PlatformIO/Projects/WSServer/include/Tiny_Websockets_Generic/internals/ws_common_QNEthernet.hpp",
	"owner": "cpp",
	"severity": 4,
	"message": "#warning Using QNEthernet for Teensy 4.1 in ws_common_QNEthernet.hpp [-Wcpp]",
	"startLineNumber": 49,
	"startColumn": 8,
	"endLineNumber": 49,
	"endColumn": 8
},{
	"resource": "/c:/Users/cytro/OneDrive/Documents/PlatformIO/Projects/WSServer/include/Tiny_Websockets_Generic/message.hpp",
	"owner": "cpp",
	"severity": 4,
	"message": "#warning WEBSOCKETS_USE_ETHERNET and USE_QN_ETHERNET in message.hpp [-Wcpp]",
	"startLineNumber": 52,
	"startColumn": 6,
	"endLineNumber": 52,
	"endColumn": 6
},{
	"resource": "/c:/Users/cytro/OneDrive/Documents/PlatformIO/Projects/WSServer/include/Tiny_Websockets_Generic/server.hpp",
	"owner": "cpp",
	"severity": 4,
	"message": "#warning WEBSOCKETS_USE_ETHERNET and USE_QN_ETHERNET in server.hpp [-Wcpp]",
	"startLineNumber": 53,
	"startColumn": 6,
	"endLineNumber": 53,
	"endColumn": 6
},{
	"resource": "/c:/Users/cytro/OneDrive/Documents/PlatformIO/Projects/WSServer/src/main.cpp",
	"owner": "cpp",
	"severity": 4,
	"message": "#warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error [-Wcpp]",
	"startLineNumber": 83,
	"startColumn": 4,
	"endLineNumber": 83,
	"endColumn": 4
}]
I can connect to the server (using Chrome WS client), but I need to add a path (as asked above). Any ideas?
 
Thanks, switching to QNEthernet works (still getting those warnings )

I can connect to the server (using Chrome WS client), but I need to add a path (as asked above). Any ideas?

I can't answer the address question, but what you posted are just warnings embedded in the code. Are you getting warnings at compile time?
 
These are the only warnings I'm getting.
I found, the address is not so important. For the time being I can live without special path.
 
Looking at those warnings. Is it possible you have some of those macros set when they shouldn’t be set? Eg. Setting QNEthernet macros concurrently with non-QNEthernet macros.

Side question: how do you get JSON error output with PlatformIO? A quick search doesn’t seem to turn up much.
 
Looking at those warnings. Is it possible you have some of those macros set when they shouldn’t be set? Eg. Setting QNEthernet macros concurrently with non-QNEthernet macros.

Side question: how do you get JSON error output with PlatformIO? A quick search doesn’t seem to turn up much.

I didn't do anything special to get json output. I just created a new project by importing from Arduino .ino file.
 
@DragonSF For the JSON output, how are you running the build? From the command line or inside an editor or IDE or something? If so, which IDE or editor? I just can't seem to get JSON output; there's just regular compiler messages. For example, are you doing `pio run`? Both `pio run` from the command line and the "Build" task in VSCode both give regular compiler messages for me and not JSON.
 
I'm using the IDE (clicking on the check or upload symbol). In the terminal I also see no json, when when I copy the messages, they are transformed into json.
 
Last edited:
Hi Khoih

I have been trying to reach to you for some help, I have a project that uses ESP8266 and W5500 Ethernet IC basically on a Pcb that I have designed, I have been using the websocket server library on another project using the ESP8266 but using its built in WIFI and it works fine, on this project however i have no use for the WIFi and need to get a websocket server running with the Ethernet2 library, my project has a web interface that uses standard Get requests as well as ftp Modbus over TCP MQTT and OTA update all via Ethernet network connection and it all works fine, I hit the wall however because if I try to use the Websockets server library (created by Links2004) it fails to connect. I assume this is because I’m using an ESP8266 and it therefore tries to use that network type that’s defined in the library. I have tried to modify and fix network type but then the old Ethernet lib include then seems to be called and I just end up with errors, I just wondered if there is a solution that allows Websocket server with an ESP8266 using ethernet2 lib.

Kind Regards

Jono
 
Back
Top