10 months ago
I am unsure about the host here… const server = Hapi.server({
port: process.env.PORT || 3001,
host: 'localhost'
}); I have been testing earlier just on my pc running a hapi server to server my websockets to help me gain real time data features to my website that I am working on just as a hobbyist. I cant seem to quite figure it out like I need some sort of NEXTPUBLICWS_URL=wss://:, but am not sure how to go about this either XD
> ⓘ Deployment information is only viewable by project members and Railway employees.
5 Replies
10 months ago
Simply replace localhost
with 0.0.0.0
As for needing NEXT_PUBLIC_WS_URL
variable please tell me why you think you may need it?
9 months ago
I’m trying to set up a WebSocket server on Railway to provide real-time data and updates for my applications. My frontend is hosted on Vercel and currently communicates with a backend using Neon. However, I need a reliable WebSocket server to manage real-time interactions and broadcast updates.
Specifically, I need to ensure that my frontend's WebSocket URL points to the correct Railway-provided WebSocket URL so that it can communicate seamlessly with the backend deployed on Railway. This setup should allow my frontend, as well as other third-party services, to access real-time data and updates through the WebSocket server on Railway, so this is atleast my idea as of right now XD
9 months ago
Then yeah a NEXT_WS_URL
variable would be a good way of doing that, in Vercel set that environment variable to something like wss://<your railway provided domain>/<your websocket path>
and then use that environment variable in the code when initiating the WebSocket connection.
9 months ago
yeah, that was the tought, but is that possible? or do you know a trick or two?
9 months ago
Of course it's possible, I think you are overthinking it.
It really is just as easy as setting the environment variable in Vercel and using it in code.