Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude default port from wss host #685

Closed
xcelder opened this issue Mar 27, 2018 · 6 comments · Fixed by #683
Closed

Exclude default port from wss host #685

xcelder opened this issue Mar 27, 2018 · 6 comments · Fixed by #683

Comments

@xcelder
Copy link
Contributor

xcelder commented Mar 27, 2018

I'm working with a server balanced by a proxy that redirect my request to the targeted server depends on the URL I requested.

One of these servers has a secure Websocket (I mean wss) and it works on the default port (443).

In your client (class WebSocketClient.java) you avoid to include the port in the host by: port != WebSocket.DEFAULT_PORT ? ":" + port : "", but this works only for ws default port and not for wss that now is including ":443" at the end of the host. In my app, for example I want to connect to "wss://app.example.com" and without this check it's trying to connect to "wss://app.example.com:443" and the proxy cannot resolve this host.

Possible Solution

Adding a check for DEFAULT_WSS_PORT as well as the check for DEFAULT_PORT it solves the problem.

String host = uri.getHost() + ( 
			(port != WebSocket.DEFAULT_PORT && port != WbSocket.DEFAULT_WSS_PORT)
			? ":" + port : "" );
@marci4
Copy link
Collaborator

marci4 commented Mar 30, 2018

Hello @xcelder,

thanks for opening this issue!

Is this proxy available for testing?

Greetings
marci4

@xcelder
Copy link
Contributor Author

xcelder commented Mar 30, 2018

Unfortunately not, is a private server in the company
I work on, but we've check the logs and the problem was that. Sorry if I cannot provide more clues... :(

@marci4
Copy link
Collaborator

marci4 commented Mar 30, 2018

Hello @xcelder,

thanks for the feedback.
No worries, I just like to check and make sure the changes really fix the issue ;)

Anyway, after you fix the typo I found in your PR, I am really happy to merch it!

Greetings
marci4

@xcelder
Copy link
Contributor Author

xcelder commented Mar 30, 2018

I fixed the typo, sorry I wrote it in the github editor and I didn't saw it.

@marci4
Copy link
Collaborator

marci4 commented Mar 30, 2018

No problem!

Thank you a lot for your changes!

Greetings
marci4

@xcelder
Copy link
Contributor Author

xcelder commented Mar 30, 2018

thank you for answering so fast! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants