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

TLS connection timeout problem #420

Closed
silence44 opened this issue Sep 4, 2018 · 7 comments
Closed

TLS connection timeout problem #420

silence44 opened this issue Sep 4, 2018 · 7 comments

Comments

@silence44
Copy link

I'm trying to set websocket connection from one golang app to another one using tls.

On client side I do just simple connect:

u := url.URL{Scheme: "wss", Host: "localhost:8000", Path: "/server_client"}
conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
log.Info("Tried connect...")

On server side I have gin gonic with TLS:

r := gin.Default()

r.GET("/server_client", func(c *gin.Context) {
	s.wshandler(hub, c.Writer, c.Request)
})

return r.RunTLS(":8000", certFilePath, keyFilePath)

And problem that code on client side just stay on dialing forever. I mean that I can't see log "Tried connect...".

After 10 minutes I killed client app process I saw on server side this message:
"http: TLS handshake error from [::1]:50194: read tcp [::1]:8000->[::1]:50194: read: connection reset by peer"

All the time I was using my local certificate and after few hours I fixed issue with custom dialer config where I set:

TLSClientConfig: &tls.Config{InsecureSkipVerify: true}

Anyway without it my code was waiting forever for something I don't understand. I think it still may be an issue for somebody. Please tell me how I can help you to provide more details about my issue.

@ghost
Copy link

ghost commented Sep 4, 2018

Show the client code that is "using my local certificate".

Kill the client with SIGQUIT to dump the goroutine stack traces and share the trace of the dialing goroutine here. To kill with SIGQUIT, type ctrl-backslash on the terminal.

@silence44
Copy link
Author

Ok, right now I rolled back my code to repeat the issue and now it does not stuck any more.

So I'm receiving normal error from dialing with message: "ERRO[0004] x509: certificate is valid for Test, not localhost". Which is normal behaviour I think.

I suppose It may be my antivirus holding connection or smth.

To my mind we can close this issue for now.

@elithrar
Copy link
Contributor

elithrar commented Sep 4, 2018 via email

@silence44
Copy link
Author

I knew that it was not valid. I was expecting to get "invalid error". But the point was that on dial program just stucked and was not able to move forward. Now somehow I can't reproduce this.

P.s. Thanks for mkcert, will check it out later.

@elithrar
Copy link
Contributor

elithrar commented Sep 4, 2018 via email

@ghost
Copy link

ghost commented Sep 19, 2018

PR #429 includes a test with an invalid certificate. The test does not hang.

@silence44 Please share anything you can on how to reproduce this problem.

@silence44
Copy link
Author

As I mentioned above I can't reproduce it anymore by myself.
I think that was my antivirus blocking program execution with not valid certificate.

To my mind we can close this issue.

@gorilla gorilla locked and limited conversation to collaborators Apr 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants