GoogleCloudPlatform / GoogleCloudPlatform/cloud-sql-go-connector

Improve error messages surrounding `serverProxyPort` port 3307

Open
#632 4 comments 0 reactions 1 assignee Assigned to @hessjcg View on GitHub
priority: p3 type: feature request
Dominant language
Go
Stars
145
Forks
35
Avg merge
3d 22h
Merged PRs (30d)
5

Description

### Feature Description

It is confusing that it uses port 3307 as `serverProxyPort`, because it resembles the MySQL port number and is some times used for the local mysql port (if 3306 is unavailable).

https://github.com/GoogleCloudPlatform/cloud-sql-proxy/issues/1841#issuecomment-1592714552
> So maybe the server side proxy component should be using a port number that does not resemble any of the ports normally used by the databases (are the proxy components using ssh, then maybe just 22 or a port number resembling ssh, for instance 2222).

https://github.com/GoogleCloudPlatform/cloud-sql-go-connector/blob/68a58cdf4c2f390e45ba09daf0e339fc15b9756d/dialer.go#L47
https://github.com/GoogleCloudPlatform/cloud-sql-go-connector/blob/f1bcda8170c7318d29de958a42ee457e8b0193b5/internal/mock/cloudsql.go#L302

### Sample code

```Go
serverProxyPort = "2222"
```

```
ln, err := tls.Listen("tcp", ":2222", &tls.Config{
```

This would also require a change in the server code.
It would probably require the connector to try to first connect to 2222 and then fall back to 3307, in case the server has not been launched with the new port yet.
The server code would probably listen to both ports, while updating all the connectors.

### Alternatives Considered

This could also instead be remedied by a better error message when the connector cannot connect to the server.

### Additional Details

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.