#Can I use an Intranet to access mysql
67 messages · Page 1 of 1 (latest)
Project ID: 95472512-a46f-4dd2-8837-da96caffebbc
You might find these helpful:
95472512-a46f-4dd2-8837-da96caffebbc
you can't at the moment, you have to access services and plugins from their public addresses, even if both in the same project
though internal networking is coming!
@orchid prism Currently i always encounter timeout problem, read tcp 172.17.2.122:49660->35,199.165.80:7806: i/o timeout problem, is this a public network problem?
are you connecting to the database with the variable references?
show me a screenshot of the service variables and how you are using them in your code
I also found that when using the local command line, the connection would be disconnected after a while
you arent using environment variables
Oh, yes, I wrote the configuration link in the code
show me please
The screenshot above is the link configuration I used
I get this error a lot in my local environment
show me the dsn variable
you arent using environment variables
Do I have to use the railway environment variable? Can I write it in the go service configuration file?
not recommended
Thank you. I'll change it to use environment variables
also, please dont build your own dsn like that, use the MYSQLDATABASE variable
Do you mean to recommend that I build all the tables under the railway database? Can I create my own database for use?
I created a database stock that can be queried in mysql-client, but cannot be found in the railway dashboard.
please just one thing at a time, let me know when you're using environment variables, and have removed all database credentials or domains from plain text files
Can I directly refer to the environment variables exposed by the mysql plugin in my service? Do I need to configure it to my service in railway?
you need to setup variable references or your service will not have access to the database
remember when i asked this, and you answered with yes. why give me increment information? that only makes my job harder when im just trying to help
please read that docs link i sent you, and once you think you have it setup, show me a screenshot of the service variables
This is right?
what is ENV for?
This is the environment variable that determines my service, prod or local
RAILWAY_ENVIRONMENT exists
but thats just an fyi, your service variables look good
now use them in code
os.Getenv("VARIABLE_NAME")
I finished it.
I use a self-created database, and I need to migrate the data if I need to switch to railway
you can do this lol
if os.Getenv("RAILWAY_ENVIRONMENT") == "production" {
// code
}
Ok, I will modify it later. Does this currently can resolve the problem of occasional timeout?
Yes, it can connect success.
so that issue is solved
But my problem is an accidental timeout, which could have been connected successfully before.

Like this one
does it time out during connection?
No, most of the time it happens when I update or insert
So I'm wondering if it's a problem with an unstable public network connection.
2023/04/15 03:45:34 /go/stock-web-be/dao/db/db.go:68 invalid connection
do you have this code in a public repo?
no, but I can provide this code
if you could put it into a repo that would be very helpful
Sorry, I seem to know why the connection is invalid. It should be that I changed the database to the railway to trigger create table