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

ipv4 vs ipv6 #1658

Closed
3 tasks
misterunix opened this issue Oct 23, 2020 · 1 comment · Fixed by #1667
Closed
3 tasks

ipv4 vs ipv6 #1658

misterunix opened this issue Oct 23, 2020 · 1 comment · Fixed by #1667

Comments

@misterunix
Copy link

Issue Description on most dual stack machines only ipv6 will bind as a listener.

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

bind to ipv4 ports

Actual behaviour

binds only to ipv6 ports

Steps to reproduce

Compile the example code and check listening ports. Only ipv6 will be listening.

Working code to debug

package main

import (
    "net/http"

    "github.com/labstack/echo"
    "github.com/labstack/echo/middleware"
)

  // Handler
  func hello(c echo.Context) error {
    return c.String(http.StatusOK, "Hello, World!")
}

func main() {
    // Echo instance
    e := echo.New()

    // Middleware
    e.Use(middleware.Logger())
    e.Use(middleware.Recover())

    // Routes
    e.GET("/", hello)

    // Start server
    e.Logger.Fatal(e.Start(":1323"))
}

The work around: in 'echo.go' change "tcp" to "tcp4"

func newListener(address string) (*tcpKeepAliveListener, error) {
        l, err := net.Listen("tcp", address)
        if err != nil {
                return nil, err
        }
        return &tcpKeepAliveListener{l.(*net.TCPListener)}, nil
}

Version/commit

@pafuent
Copy link
Contributor

pafuent commented Nov 5, 2020

I uploaded #1667 to fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants