Jump to content


Member Since 15 Aug 2019
Offline Last Active Nov 22 2019 01:37 PM

Posts I've Made

In Topic: Java Websocket Connection Failure

13 November 2019 - 12:44 PM


RewriteRule "^/Server/ANY$" "ws://localhost:8080/hhdavidh_Hide/Server/ANY" [P,L]
Does it work if you add the (.*) like Tommygun did?
RewriteRule ^socket\/(.*) "ws\:\/\/127\.0\.0\.1\:8080\/tommygun_warpaint11\/socket" [P,L]



I've now changed it to:

RewriteEngine On
RewriteRule "^Server/(.*)" "ws://localhost:8080/hhdavidh_Hide/Server/ANY" [P,L]

...however, it still doesn't work.


I should say that the reason my .htaccess looks different to his is that firstly I have tried doing a near copy (apart from necessary adjustments) of his .htaccess file however that still didn't work. And secondly, I tried teaching myself the rules of writing in the .htaccess file yesterday, and from what I've learned I think my .htaccess file should work regardless. I've also removed the RewriteConds so as to not over-complicate it if I make a mistake.

In Topic: Java Websocket Connection Failure

13 November 2019 - 01:21 AM

He cheated to make it work. He never actually got the socket to work directly, but rather he made Apache accept and pass the websocket data back to the servlet (Apache can talk to the servlet websocket via localhost even if it's otherwise firewalled in since they run on the same server). That works if the data flowing through the web socket can be handled by Apache...not everything can be. Sockets are supposed to be HTTP compatible during initial connection, so Apache should be able to pass WS data back (effectively making Apache into a proxy). I do know that WSS (secure websocket) never worked.
I'd give the method shown there a shot assuming your client can support Apache being in the middle (that's going to depend on what the client is...), but that particular user is no longer on our service so I can't really ask him if he ever got it to fully work.
As for VPSes, that's the best practice when building things like this. You have root access on a VPS and can just open the required ports vs. trying to work around the limitations of the shared hosting. Any firewall you'd run into would be one you installed yourself, so you can just add exceptions to make it work.


Firstly, VPSes aren't really an option for me at the moment as I'm not able to put money into this until after I finished my game/website. Also since I didn't want to use WSS anyway, I've done more research on WS, Apache, .htaccess and using Apache as a proxy. And from what I've learned and from tommygun's post, I've made the following changes:


Client (Javascript):

const Connection = new WebSocket("ws://hhdavidh.heliohost.org/Server/ANY");


.htaccess File:

RewriteEngine On
RewriteRule "^/Server/ANY$" "ws://localhost:8080/hhdavidh_Hide/Server/ANY" [P,L]


Server (Java):


All of this results in the same error:

WebSocket connection to 'ws://hhdavidh.heliohost.org/Server/ANY' failed: Error during WebSocket handshake: Unexpected response code: 404

On a side note, if I change the .htaccess file to this (as I found in some forums):

RewriteEngine On
RewriteRule "^/Server/ANY$" "ws://localhost:8080/hhdavidh_Hide/Server/ANY" [P,L]

ProxyPass http://localhost:8080/

...then the error changes to this:

WebSocket connection to 'ws://hhdavidh.heliohost.org/Server/ANY' failed: Error during WebSocket handshake: Unexpected response code: 500

Now, regardless if I leave ProxyPass in or out, I still don't know how to replicate tommygun's "non-encrypted websocket chatter".


Do you have any more ideas on what I can change or add? This is all new to me so any help would be appreciated.

In Topic: Java Websocket Connection Failure

12 November 2019 - 12:55 PM

Is the WAR file you're running on our server supposed to listen for non-HTTP inbound connections on a custom port? If this what you're doing, you've built a custom server daemon. Custom server daemons are not supported on shared hosting for security reasons.


You would need a VPS for that application to work properly. https://heliohost.org/vps/ (The cheapest option would work for a single app, though an extra GB of RAM would be recommended due to Java's memory-hungry nature).


There is a post on these forums that is quite similar to the problem I have:




...tommygun got a websocket working on Helio, however, there was no mention of a VPS for the websocket to work.


Now, I've tried my best to apply the steps tommygun provided in that post, but I'm still having trouble. So I guess my question is 'How would you create a basic websocket connection using a WAR file, and what would be the correct URL for it?'.

In Topic: Java Websocket Connection Failure

11 November 2019 - 01:16 PM

The 404 error makes me think that maybe the problem is the url. When our system deploys a .war your username is appended to the front so Hide.war becomes hhdavidh_Hide.war. This causes issues with some applications. Try naming your .war file with your username already on the front so it doesn't get renamed, and deploy that.


I still get an error:


WebSocket connection to 'ws://hhdavidh.heliohost.org:1234/hhdavidh_Hide/Server/ANY/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT



Assuming my war file is now called "hhdavidh_Hide.war" what part of this (below) URL should I change for it to be correct?




Also, I have seen people have their URLs without a port number (:1234). If that's the problem I have, then what port number should my server-side code use?

In Topic: Java Websocket Connection Failure

10 November 2019 - 03:08 AM

Which error? You listed two in your original post.

WebSocket connection to 'ws://hhdavidh.heliohost.org/Hide/Server/ANY' failed: Error during WebSocket handshake: Unexpected response code: 404