Skip to content

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

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!

Activity

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

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