tommygun Posted September 28, 2017 Posted September 28, 2017 Hello all, So far it's been pretty great to be able to use this service. I'm still learning the ropes here, I'm struggling to get my Java websocket up and running. I'm trying to run a small matchmaking service for my indie game Warpaint. I've got Java enabled on Tommy, and my .war is successfully deployed. Servelets respond as expected. I'm not sure exactly how to structure the url to access the websocket, or how to test that the program is listening for incoming websocket connections. Here's what worked at my last hosting solution: (wss://warpaint-l4dd3r.rhcloud.com:8443/socket) I'm aware that the default websocket ports, 443 / 8080 should work for Heliohost, so I'm trying this url: (wss://tommygun.heliohost.org/warpaint11/socket) But it's not working, and I'm not sure how I might continue debugging. Has anyone set up a Java websocket on here before? Best, Adam
Krydos Posted September 29, 2017 Posted September 29, 2017 The only ports that are open externally are ports that are already in use by services so you're not going to be able to have your servlet listen directly on any random port like 8443. Try this /home/tommygun/public_html/.htaccessRewriteEngine on RewriteCond %{HTTP_HOST} ^tommygun\.heliohost\.org$ [OR] RewriteCond %{HTTP_HOST} ^www\.tommygun\.heliohost\.org$ RewriteRule ^socket\/(.*) "http\:\/\/127\.0\.0\.1\:12001\/$1" [P,L]
tommygun Posted September 29, 2017 Author Posted September 29, 2017 Thank you so much for lending a hand! I've added a file named '.htaccess' in the folder specified. I'm unfamiliar with the rules, but I've pasted what you sent me. I'm still unable to connect, and I've exhausted my own debugging potential. Urls I've attempted to connect with: wss://tommygun.heliohost.org/warpaint11/socketws://tommygun.heliohost.org/warpaint11/socketwss://tommygun.heliohost.org/socketws://tommygun.heliohost.org/socket Perhaps I should better familiarize myself with Apache.
Krydos Posted September 29, 2017 Posted September 29, 2017 Well, first of all, the way the .htaccess is written you need the trailing /. So, if you check http://tommygun.heliohost.org/socket/ you will see a 503 error. What that means is there is nothing running on port 12001 (which is just a mainly arbitrary number I came up with.) You can edit the .htaccess to include the port you want to use.
tommygun Posted September 30, 2017 Author Posted September 30, 2017 Ok so I've been learning a lot about Apache Tomcat, .htaccess, and javax websockets. I've got the bear minimum working, thanks to Root Admin's help For anyone who's trying to set up their own Java websocket, here are some things I learned: -I had to create and edit .htaccess in my public html folder RewriteEngine on RewriteCond %{HTTP_HOST} ^tommygun\.heliohost\.org$ [OR] RewriteCond %{HTTP_HOST} ^www\.tommygun\.heliohost\.org$ RewriteRule ^socket\/(.*) "ws\:\/\/127\.0\.0\.1\:8080\/tommygun_warpaint11\/socket" [P,L] -I had to redirect my request to port 8080 for some reason-I had to change the redirect protocol from http to ws-I also had to hack the path to suit the war deployment folder: "<MyUsername>_<.warname>"-Then I had to append the server endpoint annotation "socket" in my case. That was enough to get non-encrypted websocket chatter going between my game client and my server. However, the game client won't connect with wss. Using a browser / javascript based websocket client allowed me to connect wss, so there must be something I don't know about my game client's websocket implementation.Furthermore, setting the rewrite rule to accept any string regex : (.*) didn't help, so I can assume both websocket clients are sending the same request. I might look into this further, but it works for now. Thanks again!
Krydos Posted September 30, 2017 Posted September 30, 2017 Thanks for in depth explanation of what you tried and what worked. A lot of people just never post once they figure it out, and since they didn't share their knowledge every subsequent person who tries to do the same thing has to figure it all out from scratch all over again. If you feel that your process would help others you could consider writing an article on our wiki too http://wiki.helionet.org/ 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now