Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7409007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:00:33+00:00 2026-05-29T06:00:33+00:00

Env for project: – Eclipse 3.6 (Eclipse-jee-helios) + HTML5 + JavaScript + Websocket +

  • 0

Env for project: –
Eclipse 3.6 (Eclipse-jee-helios) + HTML5 + JavaScript + Websocket + (grizzly) Glassfish 3.1.1

I have deployed sample project and able to run using GF.

When i try to connect websocket it always call onClose.

I tried: –
asadmin set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.websockets-support-enabled=true

GF 3.1.1 supports web socket (Downloaded from http://glassfish.java.net/downloads/3.1.1-final.html)

Browser like safari and Google Chrome supports websocket (i am using latest browser and checked with http://websocket.org/echo.html URL)

Java Script:-

    var webSocket;

$(document).ready(
function() {

**var URL = "ws://localhost:8080/SampleGF/WebSocketChatServlet";**

      //Tried using and lot of combination of URLS
      var URL = "ws://localhost:8080/";
      var URL = "ws://localhost:8080/SampleGF";
      var URL = "ws://localhost:8080/SampleGF/WebSocketChatServlet";

webSocket = new WebSocket(URL);

//alert("WebSockets are " + (window.WebSocket ? "" : "not ") + "supported"); 

webSocket.onopen = function(event) {
    alert("OPEN")
}
webSocket.onmessage = function(event) {
    var $textarea = $('#messages');
    $textarea.val($textarea.val() + event.data + "\n");
    $textarea.animate({
    scrollTop : $textarea.height()
    }, 1000);
}
webSocket.onclose = function(event) {
    alert("CLOSE")
}

});

 function sendMessage() {
var message = $('#username').val() + ":" + $('#message').val();
webSocket.send(message);
$('#message').val('');
}

i have used ChatSocket.java, WebSocketChatServlet.java, ChatApplication.java as it is from below link: –

http://java.dzone.com/articles/creating-websocket-chat

i have added servlet-api.jar in my project library.

Ref. Link: – http://tech.amikelive.com/node-269/eclipse-quick-tip-resolving-error-the-import-javaxservlet-cannot-be-resolved/

Web.xml: –

I have added servlet and servlet-mapping as below:

servlet

    description    WebSocketChatServlet  description 
    servlet-name   WebSocketChatServlet  servlet-name
    servlet-class  org.trivadis.websocket.servlet.WebSocketChatServlet  servlet-class

servlet

servlet-mapping

servlet-name  WebSocketChatServlet    servlet-name
url-pattern   /WebSocketChatServlet   url-pattern

servlet-mapping


I am not sure what i am doing wrong….

How can i check URL i am using is correct or not for websocket.

GF location is D:\glassfish3\glassfish for my project.
Project location D:\workspace\SampleGF

Another reason: –

Even I tried WAR sample from below link: –

http://jarvana.com/jarvana/search?search_type=project&project=grizzly-websockets-chat

WAR File Name: -grizzly-websockets-chat-1.9.45.war

I have imported above war file in Eclipse and deployed it on glassfish 3.1.1 server. After running it application always call onclose event.

I have executed below command: –

asadmin set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.websockets-support-enabled=true

and I am using browser like safari and Google Chrome supports websocket (i have tested it with below link http://websocket.org/echo.html URL)

Can anyone help me out…..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:00:34+00:00Added an answer on May 29, 2026 at 6:00 am

    It’s been months since I tried to run published sample-code against grizzly. I may be out of date, but it didn’t work when I tried it. The guy who published the sample eventually admitted problems in the discussion posts below his article. Since I haven’t tried it since, I don’t know whether it’s been fixed yet; i.e. I don’t have confirmation that grizzly works yet. (If someone knows of a working sample, I’m as interested as you are.)

    In the mean time, you can try this alternative for running your client code. You can even check what you’re doing against the free downloadable JavaScript code if you wish.
    http://highlevellogic.blogspot.com/2011/09/websocket-server-demonstration_26.html

    If you get your code to work against this server, then try again with grizzly. I’ll be interested in the results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project that is Java EE 5 running on Glassfish. The IDE
Im using python markdown for my django project, when i have the value #/usr/bin/env
I have a project built in eclipse with a dependencies on 3rd party jars.
Env.: Vista SP1, SQL Server Express 2005 I'm able to connect to my localhost
Env.: VS 2008, .NET 2.0, WinForms I have a listview in Tile mode. Some
in dirA/SConscript I have: Import('env') probeenv = env.Clone() probeenv['CXXFLAGS'] += ['-fno-rtti','-Wnon-virtual-dtor'] ... stuff that
in my project i want to use JASON parsing my sample soap request and
I have a single Django-project on standard webfaction plan (256mb ram). The average loading
I have a rails project running that defines the standard production:, :development and :test
I have a project (built from an AppFuse template) that requires Maven 2.2.1. So

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.