ws icon indicating copy to clipboard operation
ws copied to clipboard

report tls: first record does not look like a TLS handshake when dial with tls option

Open mebest100 opened this issue 5 months ago • 2 comments

Hi, it report "tls: first record does not look like a TLS handshake" when dial with tls option

And the code is as follows:

	dialer := ws.Dialer{
		Header: ws.HandshakeHeaderHTTP(header), 
		NetDial: func(ctx context.Context, network, addr string) (net.Conn, error) {
			
			rawConn, err := net.Dial(network, addr)
			if err != nil {
				log.Logf("websocket dial tcp fail, err==> %v", err)
				return nil, err
			}
		
			tlsConn := tls.Client(rawConn, tlsConfig)
			return tlsConn, nil
		},
	}

	
	conn, _, _, err := dialer.Dial(context.Background(), url)

the tlsConfig is generated by self-signed , but the same config work well with gorilla/websocket lib. Pls kindly advise the probal causes and solutions. Thx!

mebest100 avatar Oct 01 '24 13:10 mebest100