R
Railway17mo ago
guoyuyan

redis

How to connect Redis by railway connect, does a template exist to connect Redis with railway connect? Now I connect with username/password, but I'm finding a way to connect without a username. ProjectId: 38fe79a8-c127-4e50-ba67-eab1ce076502 ServiceId: e95b93c0-d4a0-4be2-8a1b-2addbf59d616
40 Replies
Percy
Percy17mo ago
Project ID: 38fe79a8-c127-4e50-ba67-eab1ce076502
guoyuyan
guoyuyanOP17mo ago
38fe79a8-c127-4e50-ba67-eab1ce076502
Brody
Brody17mo ago
there would need to be a redis plugin in the project you've linked with the cli railway connect should not ask you for a username or password to connect to redis, since that would defeat the purpose of the command
guoyuyan
guoyuyanOP17mo ago
You mean railway connect is an interactive input to connect Redis? It also needs username and password?
Brody
Brody17mo ago
it does not need a username or password
guoyuyan
guoyuyanOP17mo ago
sorry, I miss not, where is the plugin?
Brody
Brody17mo ago
have you created a project in railway?
guoyuyan
guoyuyanOP17mo ago
yes, 38fe79a8-c127-4e50-ba67-eab1ce076502 is the project id
Brody
Brody17mo ago
does that project have a redis plugin in it? (I'm just a community member I can't see anything about your project with your id)
guoyuyan
guoyuyanOP17mo ago
I add a redis server, but I don't know what is redis plugin.
guoyuyan
guoyuyanOP17mo ago
Brody
Brody17mo ago
a plugin is just the name we give to the provided databases, mysql plugin, mongodb plugin, etc but yeah that looks good to me do you have the railway cli installed on your computer?
guoyuyan
guoyuyanOP17mo ago
I want to use railway connect in the kuai server but not on my computer. Currently, I use the variable to connect it.
Brody
Brody17mo ago
railway connect is for your computer, I think you're mistaken if you want to connect to the redis database from your kuai service you are going to first need to setup all the needed variable references for redis https://docs.railway.app/develop/variables#reference-variables
guoyuyan
guoyuyanOP17mo ago
got that, I mistake thought there is exist one way to connect it to other services without username/password
Brody
Brody17mo ago
please do that and then show me another screenshot of your service variables
guoyuyan
guoyuyanOP17mo ago
I have connected Redis success with variables. Thank you for your help. I mistake thought that railway connect is used for other services.
Brody
Brody17mo ago
so all good, problem solved?
guoyuyan
guoyuyanOP17mo ago
yes, I have another problem with the private network between the two services. Do you have a template that how to use a private network?
Brody
Brody17mo ago
I do, but I'm gonna need more information on your desired usecase
guoyuyan
guoyuyanOP17mo ago
The kuai-mvp-dapp-ui is created by next, the kuai service is created by Koa, and I want to call kuai api by private network from kuai-mvp-dapp-ui
Brody
Brody17mo ago
okay one sec while I Google what Koa is okay Koa is express but better
guoyuyan
guoyuyanOP17mo ago
I have set all of the service hosts to ipv6(::1), but it seems not to call kuai success by a private network. And after I set host to ::1, the public service is also failed.
Brody
Brody17mo ago
so this request would need to be done by the next backend, the client browser of the site will not be able to call the private network, wouldnt be very private if that was possible can you show me the line of code that contains your app.listen call?
guoyuyan
guoyuyanOP17mo ago
const server = app.listen(port, host, function () {
const address = (() => {
const _address = server.address()
if (!_address) {
return ''
}

if (typeof _address === 'string') {
return _address
}

return `http://${_address.address}:${_address.port}`
})()

console.info(`kuai app listening to ${address}`)
})
const server = app.listen(port, host, function () {
const address = (() => {
const _address = server.address()
if (!_address) {
return ''
}

if (typeof _address === 'string') {
return _address
}

return `http://${_address.address}:${_address.port}`
})()

console.info(`kuai app listening to ${address}`)
})
the port and host is from variable
Brody
Brody17mo ago
and what is host and port set to?
guoyuyan
guoyuyanOP17mo ago
Brody
Brody17mo ago
delete both those variables and use this code instead
const port = process.env.PORT || 3000;

const server = app.listen(port, '::', function () {
const address = (() => {
const _address = server.address();
if (!_address) {
return '';
}

if (typeof _address === 'string') {
return _address;
}

return `http://${_address.address}:${_address.port}`;
})()

console.info(`kuai app listening to ${address}`);
});
const port = process.env.PORT || 3000;

const server = app.listen(port, '::', function () {
const address = (() => {
const _address = server.address();
if (!_address) {
return '';
}

if (typeof _address === 'string') {
return _address;
}

return `http://${_address.address}:${_address.port}`;
})()

console.info(`kuai app listening to ${address}`);
});
guoyuyan
guoyuyanOP17mo ago
thanks, I will try
Brody
Brody17mo ago
and you are calling the koa service from the next backend right?
guoyuyan
guoyuyanOP17mo ago
actually, in the next front end.
Brody
Brody17mo ago
thats not possible
guoyuyan
guoyuyanOP17mo ago
Should I use nginx to proxy these two service?
Brody
Brody17mo ago
wait let me rephrase that question are you going to be calling the koa service's private domain from the next backend?
guoyuyan
guoyuyanOP17mo ago
I guess I need proxy the request from next, otherwise, the request will send from the browser to koa service, and the browser cannot visit the private network. Am I right?
Brody
Brody17mo ago
you are correct, but you dont need a proxy, just call the koa public domain
guoyuyan
guoyuyanOP17mo ago
That's right, if I don't want to expose the koa, I need a proxy.
Brody
Brody17mo ago
you do need to expose the koa service though a proxy is just exposing the service with extra steps, it doesnt add any of the security benifts you think it would
guoyuyan
guoyuyanOP17mo ago
You are correct. Thank you very much. Have a good day.
Brody
Brody17mo ago
well that was easy, i thought id need to do some more convincing glad i could help!
Want results from more Discord servers?
Add your server