2 years ago
Project ID f5c52e95-f2b8-4b00-baf8-a33ffa98ea49
I'm super new to railway and inexperienced with website deployments generally. I got my react client deployed and am able to use it successfully, but my Chrome console shows this error ever minute or so:
WebSocket connection to 'wss://spotification-client-production.up.railway.app:7223/ws' failed
I don't see anything in the help forum related to this error. I don't have any kind of socket set up that I'm aware of. My site makes GET calls to an API in another Railway project, and also to a 3rd party API, but only when initiated by the user. What could be causing this?
1 Replies
2 years ago
they said they tried to fix it
2 years ago
didnt work
2 years ago
<:anguish:936107845039054868>
2 years ago
maybe we can get nerd @nebula to fix it
2 years ago
you're hosting a ws server
2 years ago
right
2 years ago
so that breaks basically
2 years ago
because of how railway handles thnigs
2 years ago
hi
2 years ago
WebSockets
2 years ago
fix it
2 years ago
!!!!
2 years ago
You need to use an external WebSocket service such as socket.io or link a domain. By default our proxy will terminate long lived connections for scale reasons.
2 years ago
yeah but that's not fixing the issue lol
2 years ago
it's a work around
2 years ago
We have a fix in progress (Charith is on it) but we need to wait until Private Networking first until we can start opening up non-HTTP traffic on long lived connections (ws://, tcp:// etc)
2 years ago
!!! woo hoo
I guess I don't understand about sockets and long lived connections. I didn't think my site was using sockets
2 years ago
According to your logs you do, what is your code trying to do?
2 years ago
can you share your package.json
it makes occasional api calls initiated by the user, receives a response, and processes it. calls never take more than a second
2 years ago
i think i know whats wrong
2 years ago
yup so you're running react in dev mode
2 years ago
yep, but your start script is launching the dev server
2 years ago
that d oesnt change anything
2 years ago
add serve
as a dev dependancy
2 years ago
so npm i -D serve
or yarn add -D serve
2 years ago
Staticfile provider 🚀
2 years ago
nah staticfile is wonky
2 years ago
lmao
2 years ago
actually i guess that could work
2 years ago
but its still weird
2 years ago
serve is easier imo
2 years ago
idk why we built staticfile
2 years ago
it's not very god
installing serve now. do i need to change the start script to something else?
2 years ago
yes, change it to serve -s build
2 years ago
also set the PORT
environment variable to 3000
2 years ago
you might also want to add a dev
script set to react-scripts start
to preserve the old behavior during development
Okay, I installed serve, updated some npm packages, updated start script, added dev script, added PORT=3000 and redeployed. I no longer get the socket error message. I do notice the Deploy log shows activity whenever I load the page or do a user-initiated api call. Is this normal?
2 years ago
yes
Hey Angelo. This help article does not seem to exist anymore. Do you have any other reference?
a year ago
Are you facing the same issue?
Yes. Im facing the same issue. I'm using express. This is part of my code on how it is set up.
const httpServer = createServer(app);
const io = new Server(httpServer, {
cors: {
origin: "*",
methods: ["GET", "POST"],
}
});
....
const PORT = process.env.PORT;
httpServer.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
io.attach(httpServer);
});
a year ago
Are you using a default Railway domain?
a year ago
could you also show the error you get in your console?
Definetely. Thanks for the help btw. To answer the questions:
I'm using the railway default domain for my dev code. I also have a custom domain configured with railway for my prod version.
This is the error in the console:
websocket.js:43 WebSocket connection to 'wss://api.noisse.io/socket.io/?EIO=4&transport=websocket&sid=NKUyJEI5p-soqJdaAAA-' failed:
a year ago
looks like that error is a bit cut off?
This is the complete error message:
WebSocket connection to 'wss://api.noisse.io/socket.io/?EIO=4&transport=websocket&sid=9lioIEtnQSRL-L1xAABM' failed:
value @ websocket.js:43
Show 1 more frame
Show less
a year ago
thats unfortunaly not complete, can you link to a page where i could see this error for myself?
I can add an screenshot of my console output. Btw, english is not my first language, so if I'm not explaining myself well let me know.
This is the full code for websocket.js
a year ago
all im seeing is failed:
with no error message, this isnt super helpful unfortunately, maybe you could look for extra clues in the network tab?
a year ago
maybe this is a CORS or similar error in disguise?
I will investigate further. I will check cors as well. I will reach out with an extra message if I found a helpful error or a solution in case others find it useful.
9 days ago
hey guys, has anyone found a solution to this?