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

Improve error messages surrounding serverProxyPort port 3307 #632

Open
runephilosof-karnovgroup opened this issue Sep 20, 2023 · 4 comments
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@runephilosof-karnovgroup
Copy link

runephilosof-karnovgroup commented Sep 20, 2023

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).

GoogleCloudPlatform/cloud-sql-proxy#1841 (comment)

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).

serverProxyPort = "3307"

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

Sample code

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

@runephilosof-karnovgroup runephilosof-karnovgroup added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Sep 20, 2023
@jackwotherspoon
Copy link
Collaborator

Hi @runephilosof-karnovgroup!

Thanks for the feature request on the Cloud SQL Go Connector 😄

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).

I understand that the port number being 3307 may cause some slight confusion with the similarity to MySQL default port. The reason for the proxy server port initially being 3307 was for the intention of having it actually be similar to that of the MySQL port. This was because when the Cloud SQL Proxy first launched, Cloud SQL at the time only supported MySQL databases. This obviously didn't scale perfectly and as you mentioned maybe causes a bit of confusion for Postgres or SQL Server users.

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.

Not only would this require a backend change to the proxy server and to the Cloud SQL Go Connector, it would also require changes to the other Cloud SQL Language Connectors (Python, Node, Java). On top of this we have been using 3307 as the server proxy port for years so we have to take into account that most of our customers are familiar with this and changing it purely for convenience may cause more headaches than the convenience it provides.

I will discuss this over with the team but I think a more likely solution is to provide more detailed error messages to aid in resolving errors relating to the proxy server port and to update our docs GoogleCloudPlatform/cloud-sql-proxy#1841 for the Connectors and Proxy to be more clear about the server proxy port.

Thanks again for the feature request and providing valuable insights. Let us know if there are any other pain points you found with the Cloud SQL Proxy or Go Connector and we can see what we can do 😄

@jackwotherspoon jackwotherspoon added the priority: p3 Desirable enhancement or fix. May not be included in next release. label Sep 20, 2023
@enocom
Copy link
Member

enocom commented Sep 20, 2023

@runephilosof-karnovgroup Can you elaborate on the problem you're trying to solve? The proxy server port should mostly be an invisible implementation detail. The only place it matters is where people want to lock down their firewall and would need to allow this port.

@runephilosof-karnovgroup
Copy link
Author

If connection fails you will see this error message

Listening on 127.0.0.1:5432
accepted connection from 127.0.0.1:58436
failed to connect to instance: Dial error: failed to dial (connection name = "xxx"): dial tcp x.x.x.x:3307: i/o timeout

Which can be quite confusing, because that implementation detail is so invisible, that it is not obvious what is causing the problem, especially if you start thinking 3307 has something to do with MySQL, when you are trying to use it for PostgreSQL.

@jackwotherspoon jackwotherspoon changed the title Use 2222 for serverProxyPort instead of 3307 Improve error messages surrounding serverProxyPort port 3307 Sep 21, 2023
@jackwotherspoon
Copy link
Collaborator

Hi @runephilosof-karnovgroup! I have updated this bug to track improving the error messages surrounding the server proxy port. Hopefully more detailed error messages will help resolve the confusion, if they do not we can take another look at the port number itself. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants