Skip to content

WebSockets in Jelastic: Better, Faster, Stronger

by Marina Sprava on August 20, 2012

Would you like to make your application faster, more efficient, and more scalable? We are very happy to tell you about another great and useful add-on within Jelastic Cloud PaaS - WebSockets.

“WebSockets?”, you say. Just take a look on the benefits you can get with them, and you will agree.

WebSockets are part of a long expected evolution in client/server web technology. They allow a long-held single TCP socket connection to be established between the client and server which allows for bi-directional, full-duplex messages to be instantly distributed with little overhead, resulting in a very low latency connection.

Benefits of using WebSockets:

  • Reducing unnecessary network traffic and latency using full-duplex through a single connection
  • Streaming through proxies and firewalls, supporting simultaneously upstream and downstream communication
  • Backward compatible with the pre-WebSocket world by switching from an HTTP connection to WebSockets

Let’s deploy a sample application that uses WebSockets you that you can see how easy it is.

Create an environment

1. Go to jelastic.com and sign up if you haven’t done it yet or log in with your Jelastic credentials by clicking the Sign In link on the page.

2. Click Create environment to set up a new environment in Jelastic.

3. In the Expert environment topology window, select GlassFish as your application server and switch on Public IPv4 for it. Pick Maven as your build node and type your environment name, for example, web-socket-test. Then click Create.

In a minute, your environment with both GlassFish and Maven will be created and appear in the environment list.

Build and deploy a project

1. Click on Add project button for Maven.

2. In the dialog, navigate to Git  tab (or SVN tab). Specify your project name, Path to your project, BranchLogin and Password of your repository, the name of your EnvironmentContext in which you will deploy your project and click Add. We use a simple chat application as an example. You can find this project here.

Now your project is successfully added.

3. Click on Build and deploy button for your project.

This process can take several minutes. Your project will appear in the context that you have specified and you will see a war file in the Deployment Manager.

Configure GlassFish

1. Go to GlassFish admin panel and log in with credentials, which Jelastic sent you, when you created the environment.

2. Navigate to Configurations -> gfcluster-config -> Network Config -> Protocols -> http-listener-1, select HTTP tab and enable Websockets Support. Don’t forget to save the changes!

3. Restart GlassFish.

Start an application

Open your application in a web browser and ensure that it works fine.

Done. Have you ever deployed an app with WebSockets easier than that?

From → HowTo, Info/Edu

10 Comments Leave one →
  1. Yulia, thanks, but this is still going through Nginx correct? If so, are you sure that Nginx will be able to reverse proxy the websockets connection to Glassfish and back? Last time I tried to do this I required a specific Nginx patch which wasn’t compatible with the most recent websockets protocol (there are many).

    Note: we’re talking about websockets, not comet, the two are different.
    Comet is definitely doable with Nginx and Glassfish.

    I have had production success bridging websockets to the JVM using both:
    a) NodeJS – Redis – JVM
    b) Vert.x (which uses Netty).

    My 2 cents: provide Vert.x and/or Nodejs.
    Either way, you should definitely provide Redis.

    Dave

    • Hey, Dave! Actually my name is Marina:)))
      Theoretically it’s possible, but unfortunately we don’t provide full access to NGINX from dashboard. But we plan to add this feature in our next releases.
      And thanks for your great suggestion! You can vote for these features here http://jelastic.com/?features
      The more votes a feature gets – the higher priority it gets in the roadmap.

      • Davem permalink

        Marina – sorry about the name, for some reason your post shows up in my gmail inbox with ‘Yulia’ in the from box. Dave

  2. Davem permalink

    hmm, just upgraded our account to paid, and tried to set up a Glassfish server.
    Seems like the minimum monthly amount is $100! (ie: you need at least 6 cloudlets, plus IPv4)
    – is that correct??
    If so, it’s 5x more than the cost of doing this with rackspace, linode, amazon, heroku, etc.

    Dave

    • Hi, Dave!
      How many hours do you need to deploy and support your app on Rackspace, Linode, Аmazon, Heroku?

  3. mo6753814 permalink

    Hello,

    I have downloaded your example. And can’t launch it . I turn on websockets, and run it. Maven downloaded all dependencies and nothing.
    No errors in js console. No errors in log. But words that i send, do not appear in chat.

    Also I have 101 Switching Protocols.

    Maybe you can advice me something.

Trackbacks and Pingbacks

  1. WebSockets in Jelastic: Better, Faster, Stronger « Jelastic — Die nächste Generation Java-Hosting-Plattform
  2. Remote Debugging in the Cloud: Easier than Ever « Jelastic — Rock-Solid Java in the Cloud, Java Server Hosting, Java Cloud Computing

Account registration failed

We suspect that this is due to network issues - so please try again in a minute. If your second attempt fails please email us at info@jelastic.com and we will get you in.

%d bloggers like this: