Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPV6 Webserver. #39

Open
redDott opened this issue May 15, 2019 · 1 comment · May be fixed by #82
Open

IPV6 Webserver. #39

redDott opened this issue May 15, 2019 · 1 comment · May be fixed by #82

Comments

@redDott
Copy link

redDott commented May 15, 2019

Hi I've tried you HTTPS-and-HTTP.ino excample and it works fine for IPv4.
Currently I'm trying to use IPv6 instead.
I have configured the WIFI to get an IPv6 addres which works fine I can ping the address.

then I have changed your code of HTTPServer to use IPV6 sockets.

uint8_t HTTPServer::setupSocket() {
  // (AF_INET = IPv4, SOCK_STREAM = TCP)
  _socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_IPV6);
  if (_socket>=0) {
    _sock_addr.sin6_family = AF_INET6;
    // Listen on all interfaces
    struct in6_addr lo6 = IN6ADDR_LOOPBACK_INIT;
    _sock_addr.sin6_addr = lo6 ;
     Serial.println("_bindAddress");
    // Set the server port
    _sock_addr.sin6_port = htons(_port);
    // Now bind the TCP socket we did create above to the socket address we specified
    // (The TCP-socket now listens on 0.0.0.0:port)
    int err = bind(_socket, (struct sockaddr* )&_sock_addr, sizeof(_sock_addr));
	#if LWIP_IPV6
		Serial.println("ipv6");			
	#endif /* LWIP_IPV6 */

But connecting with curl to the IPv6 address i'm getting a connection refused.

When the ESP32 is not running I'm getting timeouts for ping and curl. If I try curl with IPv4 I get the expected output.
Any hints where I have to look in the code for IPv6 support?
Regards
Matthias

@fhessel
Copy link
Owner

fhessel commented May 15, 2019

Hi,

First of all: I edited your comment to enable C++ highlighting and make it more readable, I hope that's okay.

I haven't worked with the IPv6 stack by now, so I don't know about the common pitfalls there. In general, the HTTPServer::setupSocket(), HTTPConnection::initialize(), HTTPConnection::closeConnection() and maybe HTTPServer::teardownSocket() methods most likely will need adjustment, as they deal with socket creation and teardown; methods in HTTPServer for the server socket, and methods in HTTPConnection for the client-specific socket.

And then there are writeBuffer() and readBytesToBuffer() in HTTPConnection, which handle the actual data, maybe they need other parameter types as well.

This should be all functions that make direct calls to the socket API, so that's the first thing I would look at, if I wanted to implement IPv6 support.

Then, these methods are all overridden in the HTTPS version of the classes, to wrap the plain socket with a TLS layer. Once the plain HTTP variant is running, these methods have to be investigated to support HTTPS as well. I assume that will be the easier part.

Sadly, I don't have the capacity at the moment to analyze why exactly your code doesn't work.

@vinicentus vinicentus linked a pull request Apr 13, 2020 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants