WebSockets in Jelastic: Better, Faster, Stronger

By August 20, 2012 HowTo, Info/Edu 15 Comments
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

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, Branch, Login and Password of your repository, the name of your Environment, Context 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?

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInEmail this to someone

15 Comments

  • […] Artikel in unserem englischen Blog geschrieben, den wir Euch nicht vorenthalten wollen. WebSockets in Jelastic: Better, Faster, Stronger Share this:TwitterFacebookLinkedInMehrE-MailDruckenRedditDiggStumbleUponTumblrPinterestGefällt […]

  • Dave M says:

    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

  • Davem says:

    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?

      • Also of course Heroku doesn’t support GlassFish (or any JEE server). The only way to do it at Heroku is embedded, which is not to be recommended!

        Jelastic gives you a choice of 2 proper JEE servers (TomEE or Glassfish) so you can write your application in the normal way, and it remains portable to any other JEE server in future (so you’re not locked in to using Jelastic – you can take that same code and use it anywhere else); Heroku is the only PaaS in that list, and the way they support Java basically leads to vendor lock-in.

        The others (Rackspace / Linode / Amazon) are not providing you with anything except a raw server – so everything is down to you. You can do “anything” on those servers, but it’s 100% your job to configure and maintain it.

        Also YMMV with tech. support at those companies if you need their assistance to get everything working (e.g. Amazon will charge you extra for it); not sure on support policies for the others on this particular issue.

  • mo6753814 says:

    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.

  • Eric A. Gravel says:

    Is WebSocket only supported by GlassFish in Jelastic or can Tomcat 7 do the same?

    • Marina Sprava says:

      Yes, sure. You can do the same using Tomcat 7: switch on Public IP for Tomcat, if you use one server instance, or switch on Public IP and configure TCP balancing for NGINX load balancer if you need two or more servers. I’ll try to prepare the similar instruction for Tomcat in the nearest future.

Leave a Reply

Subscribe to get the latest updates