2 years 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.
113 Replies
2 years 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?
2 years 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
2 years 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 }, ] }
2 years ago
that's what a mongo replica set is, you can not just delete them
2 years ago
correct
2 years 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
2 years ago
then it's likely you will pay less for the database on railway, but that's not a promise
2 years 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
2 years ago
because that logs to stderr
2 years ago
you can create your own logger and set the output to stdout
2 years ago
no problem!
2 years ago
correct
2 years ago
if you don't actually need a logging framework, yes
2 years ago
though id highly recommend looking into slog, railway has great support for structured logging
2 years ago
I feel ya
2 years ago
you would need to use the public host and port
2 years ago
In the service settings
2 years ago
I think that template comes with a public TCP proxy
2 years ago
yes correct
2 years ago
that's a different bost
2 years ago
Postgres FTW
2 years ago
Thats fair
2 years 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
2 years ago
yeah -
2 years ago
whats your usecase for static outbound ips?
2 years ago
May I ask whats tricky about the mongo replica set template?
2 years 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
2 years ago
hmm, does the template not come with a public url?
2 years ago
you can! click the removed deployments 3-dot menu and then click redeploy
2 years 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
2 years ago
this is a private domain
2 years ago
you would have had to put the internal domain in compass in one way or another
2 years ago
odd, guess compass had something cached
2 years ago
Fair enough



