Friday, March 6, 2020

[google-cloud-sql-discuss] Re: Why my java program keeps connecting to Cloud SQL via cloudsqlproxy

Hi, Khanh

Quite rightly, leaving a MySQL Username unrestricted as you have done implies the user account is configured to connect from any host, however as indicated in this documentation[1] for example, if you are connecting to your CloudSQL Instance using IP addresses, you are still required to specify the client IP address as an Authorized address. The CloudSQL proxy however helps to avoid this configuration by providing secure access to your CloudSQL instance without having to add Authorized networks or configure SSL[2].

As rightly indicated in the comment by Kurtis above, the Cloud SQL Socket Factory for JDBC drivers should provide the same functionality[3][4]. The JDBC socket factory provides an alternative to the client-side proxy software. Your code seems to show that you are using the CloudSQL Socket Factory for JDBC. The CloudSQL API needs to be enabled to use the JDBC socket factory. Can you confirm this is enabled?

Reviewing the details provided in your issue description, it is unclear what exactly may be wrong with your implementation, however, this issue still seems to relate to your implementation. I suggest you review this sample implementations[5][6] for better understanding. Better still, if you require further assistance, it is best to contact the GCP Support[7]. This way a GCP Support Engineer would be able to review the details with you. 

[1]https://cloud.google.com/sql/docs/mysql/users#mysql_user_account_format
[2]https://cloud.google.com/sql/docs/mysql/sql-proxy#what_the_proxy_provides
[3]https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory#cloud-sql-socket-factory-for-jdbc-drivers
[4]https://cloud.google.com/sql/docs/mysql/connect-external-app#before_you_start
[5]https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory/blob/master/README.md#examples
[6]https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/cloud-sql
[7]https://cloud.google.com/support-hub

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/212bf5f7-5bee-49f6-a56d-b34fdd5633a6%40googlegroups.com.

No comments:

Post a Comment