Server returns 504 after exactly 5 minutes.
Hello, I am fetching an API endpoint hosted on railway and made with spring boot, this endpoint will itself do some stuff aswell as call other public endpoint that takes 2-10 mins to be available, therefore the returning object to my frontend takes that time to happen.
After exactly 5 minutes, backend returns a 504 to the frontend, which doesnt happen when I run the backend locally, any clue?
19 Replies
Project ID:
bc72ed00-77ac-4952-811c-d4f8c525ad7b
You might find these helpful:
- no 'access-control-allow-origin' header is present on the requested resource
⚠️ experimental feature
bc72ed00-77ac-4952-811c-d4f8c525ad7b
@Grand Gambit - your application is timing out. Your API needs to deliver it's response quicker than 3 minutes or else we kill the connection.
Is there any way to modify that?
Also, it ALWAYS times out after 5 mins not 3
What are you returning in your API?
Yea, so something must be happening with your code.
How big is the expected object?
not big at all
frontend calls endpoint
then backend does some stuff
and fetches for a transaction in a blockchain to be confirmed (2-10 mins)
thats your issue
and once the transaction is confirmed, it builds and returns an object
So when you have a major async operation, my suggestion is to keep a running cache of chain transaction state
reference that
Anyways, it does seem like its an issue with your code. Not with Railway. I wish it was so we can just fix it 🙂
I think that it has something to do with railway, because when I run the server locally, it does not return the 504 after exactly five minutes
this fetch is done several times, it fetches it and if the returned code is a 404(blockchain tx is not confirmed) it does the call again every 10 seconds
If you need a long running connection while you are awaiting you need to use something like a websocket.
Not REST
until it is confirmed and the blockchain api call returns a 200
Oh hmm
All platforms will kill the API call after 5 minutes.
Not only us.
I will read more about that I guess, also im a junior dev so please excuse my low knowledge
I see
Its okay! It's not super obvious hehe
Will research about that websocket thing, appreciate it!
Np!