The OpenShift forums have been retired, but you can still read and search them.
For the most up-to-date information about how to use OpenShift please visit

Websockets in Java

I'm trying to use websockets in my Java app. I used diy app, installed Tomcat 7 on it - simple applications are deploying but i don't have any luck trying to do websockets (used 8000 port).

I installed Tomcat 7 on my own PC, and all seems to be working (including websockets).

Does anyone succesfully use java websockets on openshift?

Restrictions from this KB apply: Please check it out.

@dopehate, it should work -- what's your app dns name ($app-$

Here's a sample application Tomcat7 application I just created and the websocket echo example
is at:

Quickstart+ instructions are on github:



I tried using your github Quickstart. My app is at

Did exactly as readme said, and still experiencing troubles:

  1. responds 302 - Moved Temporarily, and redirects me to

  2. if you go to, press Messages or Streams and add 8000 to name (like ws:// - respond is

Info: WebSocket connection opened.
Info: WebSocket connection closed.

It instantly closes after if opens.

@dopehate, hmm, works for me on node99 ... this looks to be a configuration issue (no routes)
on node18 where your gear is located. Will contact ops and check what's going on and update this thread.

Thanks for your patience.

@dopehate, this has now been fixed in production (routes weren't getting dynamically read/added).
Your app/the websockets example at:
works fine now.

Thanks for your patience.

I've just tested examples, and my own test app - all works fine!
Thank you a lot!

@ramr, I've exactly the same Problem. How did you solve it? Here is my Link to the websocket:

Hi there, can i know how to make the websocket echo example work on openshift? I can't connect through the websocket, it closes automatically whenever i try to connect, any help? The error echo:

THanks Nam, previously I have refered to the website you mentioned, I have followed and tried with the port 8443 but it's still not working, still the same issue. Could that be the source of issue from server.xml? I followed this website:

Everything working well except websocket.

I have the same problem with the connection of the websocket. After connecting it closes immediately. I've read that there is someting with the routes-configuration. Has anyone a solution yet?

Here's a blog related to your issue that has some suggestions:

Can you please take a look at it and see if it helps?

Hey, Thanks for your suggestion, but it still doesn't work. The port which i use is 8000.

It seems to be the same problem as dopehate had.

Any other help?

So just to be clear, your application should continue using port 8080 to serve (I'm currently getting a 503 which means the app is not reachable). Once your app is running, and you're getting responses on, then you can try the various different websocket ports from your client.

Reason being, there are a couple of proxies for you app. One which services normal http requests through (or directed to your app running on http://$OPENSHIFT_INTERNAL_IP:$OPENSHIFT_INTERNAL_PORT, and the other is (or for websocket connections.

If either isn't responding, please let us know what errors you are getting in your logs:

stefan commented on a thread in the OpenShift forum:

Hey, I also try to use tomcat with websockets. I installed it after this tutorial: [1]

Everything runs fine, except the websocket examples in tomcat. [2] Looks like dopehate had exactly the same kind of problem with the same
application. How did you solve that? Do I have to change something in tomcats config

If you need some logfiles, just tell me where I can find it.

Some additional notes: - The tomcat websocket tutorial [3] is not working - You should mention in the rhc - application, that it is not possible to
create an app that is called "new"

@stefan, I'm checking with ops. Feel free to hop on IRC when you get a chance as well. We might need your help in resolving this (like uuid info and the like). When on, ping nduong.

@stefan, after reviewing, looks like the routes are in place for your websocket connectivity. Seems the version of Tomcat may have issues. Can you try the latest (7.0.39) to see if that helps? There's been some bug fixes related to websockets since 7.0.29.

Thanks for your advice, I installed the latest version of tomcat. However, the issue remains. You can find the tomcat websocket example at:

Here is my server.xml:

I installed tomcat in the /repo/diy/ directory. Logfiles seem to be ok so far.

Any other ideas about this?

Edit: Latest version of tomcat (7.0.39) now also at

Thanks for the details. I'll reach need to reach out to a few folks on the details and get back to you.

I just gave the updated quickstart a try:

After updating the .openshift/lib/utils to download version (tcversion="7.0.39"), it's working great. Thanks @ramr!!

Here's my URL (leaving it up for a couple days):

Thanks a lot, everything works fine now.