Timeout issue Convex API via Middleware.
Hi, I am trying to call convex api from a node.js middleware. Everything seems to work fine when I am running it locally but once deployed to Railway. There is a timeout issue with the api.
The server tries to connect with convex but it fails.
Any Idea?

20 Replies
That
ENETUNREACH
ending with - Local (:::0)
looks sus, any hardcoded addresses anywhere in your code?Nope, Nothing as such, for this one I passed a hardcoded convex url (for testing) but everything is from env other than that there is fastify websocket connection where this call gets invoked
Is this self hosted?
Nope
Can you share the code with the api call
Yeahh sure
this is where I am actually calling I have created a function for query that I am sharing with this

I hard coded the url currently to test but it's not hardcoded in general

When you say running it locally works, are you running against a local or cloud deployment?
Against a local, how you usually test your api, "npm run dev" then with the local host url you hit in my case using postman with this host http://localhost:3001/try-convex with some args, this works fine and returns the data but I have it deployed somewhere and it's a different domain that is accessing convex but I am assuming the APIs are public and that should not cause an issue.

Can you try running convex dev on your machine against a cloud dev instance
If it happens there we can cut railway/production out of the issue and just debug in dev
Ummm, this is not a convex project, it's a separate node application altogether with some logic for websockets.
That's fine, I imagine you can run that node application locally. Run it locally against a Convex cloud dev deployment. If the issue reproduces, you can debug it locally.
Okay, I am clueless now! I should just convex dev in the node-apps and this should work fine?
Oh Gotcha, on a side server i locally run convex then hit this url. I've tried that, the request doesn't reach to my local at all
So you know how you can run the Convex dev server either locally or in a cloud deployment?
npx convex dev --local --once
this right? I haven't tried it
So when you're running convex dev locally, are you using that local flag or just npx convex dev
nope not yet, I haven't ran it locally
Everything seems to work fine when I am running it locallyWhat did this mean? Are you running your node app locally against your production convex deployment?
Yess this
I understood a little let me try this.