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

Host header is specified and is not an IP address or localhost #505

Closed
m7shapan opened this issue Nov 2, 2019 · 2 comments
Closed

Host header is specified and is not an IP address or localhost #505

m7shapan opened this issue Nov 2, 2019 · 2 comments

Comments

@m7shapan
Copy link

m7shapan commented Nov 2, 2019

What versions are you running?

$ go list -m github.com/chromedp/chromedp
v0.5.1
$ google-chrome --version
chromedp/headless-shell:latest
$ go version
golang:1.13

What did you do? Include clear steps.

I'm trying to connect to headless-shell from another container but this message appear to me Host header is specified and is not an IP address or localhost

What did you expect to see?

nothing I expected my app to work

What did you see instead?

Host header is specified and is not an IP address or localhost error message and app exsit

@m7shapan
Copy link
Author

m7shapan commented Nov 3, 2019

I used this workaround to overcome this issue, so I set HOST header to localhost
but that affected webSocketDebuggerUrl so at the end I replaced it with the real one at the end

func getDebugURL() string {
	client := resty.New()
	resp, err := client.R().SetHeader("HOST", "localhost").Get("http://chrome:9222/json/version")
	if err != nil {
		log.Fatal(err)
	}

	var result map[string]interface{}

	fmt.Println(string(resp.Body()))
	err = json.Unmarshal(resp.Body(), &result)

	if err != nil {
		log.Fatal(err)
	}
	return strings.Replace(result["webSocketDebuggerUrl"].(string), "localhost", "chrome:9222", 1)
}

@mvdan
Copy link
Contributor

mvdan commented Nov 6, 2019

Yes, this is a restriction of the devtools protocol. We do something similar in our codebase; grep for forceIP. I don't think there's anything here to fix. If you're talking to the JSON API directly, you should deal with these details.

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

No branches or pull requests

2 participants