Request failed: Application error
Hello, my app was working perfectly for 2 months, and today API keeps returning error code, only redeployment is helping.
be16331c-c1f2-481b-ab18-12bfc74c9ff9
35 Replies
Project ID:
be16331c-c1f2-481b-ab18-12bfc74c9ff9
could you please share your repo?
I am using socket.io, and at one specific moment, all sockets were disconnected:
Socket disconnected transport error
Socket disconnected transport error
And mongodb server connection was lost:
MongooseServerSelectionError: connection timed out
at Function.Model.$wrapCallback (/app/node_modules/mongoose/lib/model.js:5195:32)
at /app/node_modules/mongoose/lib/query.js:4901:21
at /app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
at new Promise (<anonymous>)
at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
at model.Query.exec (/app/node_modules/mongoose/lib/query.js:4900:10)
at model.Query.Query.then (/app/node_modules/mongoose/lib/query.js:4983:15)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
reason: TopologyDescription {
type: 'Single',
servers: Map(1) {
'containers-us-west-159.railway.app:7849' => [ServerDescription]
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}
you can't connect to your app over any other external port other than 443
it shows there that you're trying to connect to port 7849, that's the internal port, and not accessible externally, use 443 aka no port with the https scheme
But why it was working all the time?
it would have never worked if you where trying to connect to port 7849 externally, I can promise you that
For example, after redeployment, it is working right now
repo please
But I am sure, after 1-2 hours it will crash again
bruh I can't read, I'm so sorry
that's the address for the database
I'm really sorry
Repo is private, can you send me your email so I can add you?
Added
have you recently upgraded to dev plan?
Yes
how recently?
Jan 27, 2023
that's not recently
Oh
Is it a problem with some rate limits?
I look at repo soon, am on mobile right now and reviewing code on mobile is not fun
Ok
are you using a railway provided mongodb?
Yes
you are using
process.env.DATABASE_URL
in the mongoose connection function, but you want to be using process.env.MONGO_URL
please remove DATABASE_URL
from your service variables and then setup the correct variable references with their default names, then use process.env.MONGO_URL
in db.js
https://docs.railway.app/develop/variables#reference-variablesOne sec
Done
show me a screenshot of your service variables please
My socket io server uses 8065 port, and I included PORT variable to 8065 in service variables
you can remove PORT from those variables, railway will then inject its own auto generated PORT and then you can just have your code listen on
process.env.PORT
also dont run your app with nodemon on railwayCan be these problems the reason of application error?
this could be
this
and this, are just improvements
Ok, thank you very much
I will definitely let you know the progress
do those two improvements i mentioned too 🙂
I read every letter of your messages twice, so I'll definitely do
love to hear it!
do this then you wont need to define any custom start commands in the service settings