Skip to content

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

@mebest100

Description

@mebest100

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions