10 months ago
Hi, i'm getting this issue in my code with MongoDB
2024/07/28 23:24:54 (Location40573) The $changeStream stage is only supported on replica sets
I'm unsure how to approach this using native Railway MongoDB as I had been using DigitalOcean prior to this and they just configured it for me automatically.
Tried adding an environmental variable for REPLICASETNAME but that didn't do anything. Just needed for 1 mongo instance. Any help is appreciated.
0 Replies
10 months ago
the replicas option you see in your service settings has absolutely nothing to do with mongo replicas despite the same name, and it's absolutely not what you want.
are you using prisma?
10 months ago
an orm
quite simply all i did was plug in the mongodb private uri from railway in place of the one i got from digitalocean
10 months ago
something in your code requires a mongo replica set, you have a few options-
remove that requirement
deploy the mongo replica set template
continue using the digital ocean database
and now it errors this:
2024/07/29 00:09:30 server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: mongo1.railway.internal:27017, Type: RSGhost, Average RTT: 1288054 }, { Addr: :27017, Type: Unknown, Last error: dial tcp :27017: connect: connection refused }, { Addr: :27017, Type: Unknown }, ] }
10 months ago
that's what a mongo replica set is, you can not just delete them
10 months ago
correct
10 months ago
Vs digital ocean, not sure, never ran a database on DO
its on the more expensive side i just did it with the free credit when i started and didnt care enough to switch
10 months ago
then it's likely you will pay less for the database on railway, but that's not a promise
10 months ago
plus you will not be charged egress fees for communicating with an external database
btw another thing ive been wondering you may be able to answer, when i use log,Println in Go it makes the logs red for some reason on the railway UI
10 months ago
because that logs to stderr
10 months ago
you can create your own logger and set the output to stdout
10 months ago
no problem!
10 months ago
correct
10 months ago
if you don't actually need a logging framework, yes
10 months ago
though id highly recommend looking into slog, railway has great support for structured logging
10 months ago
I feel ya
10 months ago
you would need to use the public host and port
10 months ago
In the service settings
10 months ago
I think that template comes with a public TCP proxy
10 months ago
yes correct
10 months ago
that's a different bost
10 months ago
Postgres FTW
10 months ago
Thats fair
10 months ago
You can get a static outbound ip on the Pro plan
whole reason im even not using my digitalocean db rn is because it requires you to access from a certain ip
10 months ago
yeah -
10 months ago
whats your usecase for static outbound ips?
10 months ago
May I ask whats tricky about the mongo replica set template?
10 months ago
Care to share what there is to figure out? would love to know how we can improve the template
the simplicity of just being able to copy the url on the DO managed service
i also noticed that once i removed the deployments i couldnt seem to get it back on
10 months ago
hmm, does the template not come with a public url?
10 months ago
you can! click the removed deployments 3-dot menu and then click redeploy
10 months ago
that was a private url
i deleted it now but i saw there was a private one too it isnt the one i was using
10 months ago
this is a private domain
10 months ago
you would have had to put the internal domain in compass in one way or another
10 months ago
odd, guess compass had something cached
10 months ago
Fair enough