Websocket issues
kuhamaven
PROOP

2 years ago

I'm deploying a backend made on Java Spring with railway. Never had any issue on the past year, but I added it websockets features on this last update. When testing and running everything locally it worked perfectly, but after deploying and changing the URL to poiint to the railway deployment, I can't connect at all.

Closed

38 Replies

kuhamaven
PROOP

2 years ago

c17693fa-8f81-4f00-ad4d-8f231f687806


2 years ago

what is the exact url you are using


kuhamaven
PROOP

2 years ago

When running locally connecting to:

ws://localhost:8002/ws?token= with the correct token connects perfectly


kuhamaven
PROOP

2 years ago

changed it to the public railway url like I did for all HTTP requests:


kuhamaven
PROOP

2 years ago

wss://vpet-server.up.railway.app/ws?token=


kuhamaven
PROOP

2 years ago

and it can't connect at all


kuhamaven
PROOP

2 years ago

There is a log on the server that prints when a connection gets established, but the socket never opens at all


2 years ago

does your http server and websocket server listen on different ports?


kuhamaven
PROOP

2 years ago

nope


kuhamaven
PROOP

2 years ago

locally both run on 8002 without issues


2 years ago

what error does the console logs in the browser print?


2 years ago

and just to clear up any confusion, this would not be a platform issue


kuhamaven
PROOP

2 years ago

It's strange, now I managed to connect through postman to the railway wss


kuhamaven
PROOP

2 years ago

but with the exact same url from the actual client (Made sure by making it print the url+token and pasting it into postman) and the client gets instantly replied with a closed websocket by railway


kuhamaven
PROOP

2 years ago

printing the state goes from "Connecting" to "Closed" but when running locally it goes from "Connecting" to "Opened"


2 years ago

we are not closing the connection, this would be an issue with your application's code or configuration, from either your server or client


2 years ago

^


kuhamaven
PROOP

2 years ago

1307901066460926093


kuhamaven
PROOP

2 years ago

It doesn't give any error at all


kuhamaven
PROOP

2 years ago

in the railway logs it never shows the connection opened in the first place


2 years ago

You would want to add better error handling so that you can see the reason it fails to connect, or the reason your application does not accept the connection


kuhamaven
PROOP

2 years ago

That is what's throwing me off. There are logs for any error message that gets thrown as I could test everything when running locally


kuhamaven
PROOP

2 years ago

1307901794537705512


kuhamaven
PROOP

2 years ago

All I do different between local and deploy is switching the BaseURL field


kuhamaven
PROOP

2 years ago

locally after a connection I can see the closing reason, status and everything


kuhamaven
PROOP

2 years ago

but here I don't even get connected in the first place


2 years ago

without proper error logging and just general verbose logging it is going to be quite hard to debug the issue with your code


kuhamaven
PROOP

2 years ago

Okay, it's refusing the connection with a code 1015


2 years ago

have you looked into why your code or configuration could be causing that?


kuhamaven
PROOP

2 years ago

All I'm finding related to said error are SSL certificates related errors


kuhamaven
PROOP

2 years ago

but I thought railway handled the certificates


2 years ago

we do


kuhamaven
PROOP

2 years ago

@Brody is there a way to check which TLS version railway is using?


2 years ago

1.1 and 1.2


kuhamaven
PROOP

2 years ago

welp, the Unity library wasn't compatible with Railway's certificate it seems


kuhamaven
PROOP

2 years ago

had to change to a different library and it now works all fine


kuhamaven
PROOP

2 years ago

So just as for future reference, if anyone is trying to use WebSocketSharp to connect to Railway, it won't work due to WebSocketSharp issues


2 years ago

glad you where able to figure out the issue with your code, and thank you for the follow up!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...