Jump to content

Java Websocket On Tommy - Default Ports / Debugging General Help


tommygun

Recommended Posts

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

Link to comment
Share on other sites

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/.htaccess

RewriteEngine 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]
Link to comment
Share on other sites

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/socket

ws://tommygun.heliohost.org/warpaint11/socket

wss://tommygun.heliohost.org/socket

ws://tommygun.heliohost.org/socket

 

Perhaps I should better familiarize myself with Apache.

 

 

 

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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/

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...