File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes WebSockets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "WebSockets" Watch "WebSockets" New topic
Author

WebSockets

Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 349
I'm trying to get started on WebSockets. First thing - just want to write (or copy-paste to create) a simple client / server. After that, my first real application is likely to be simple (sort of, I mean as far as the WebSockets part is concerned). I have some data being generated elsewhere, that will be sent from the server to the client (to animate a graphic actually - but I don't think that matters here).

1. A few weeks ago, I found it easy to discover which version of Google Chrome is actually supposed to be supporting WebSockets (version 4) and was able to find the web page to download it. Now, I've been googling for about an hour and all that seems to have disappeared from current reality. Anybody got a download page for Chrome 4?

2. Just need that really great perfect up-to-date tutorial on WebSockets with both javascript (client) and java (server) code in it. Do you know of one? Not a framework, kit or etc. please. I'm looking for something at the basic Java Trail tutorial level where I go through the tutorial and then implement the whole beginner's thing (with their code).


Correlation does not prove causality.
mohit girdhar
Greenhorn

Joined: May 24, 2011
Posts: 1
hello..
i just want to implement chat window like facebook..
how can i do this.
please tell me as soon as possible..
my e-mail id is <removed>
Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 407
    
    1

I've been playing with websockets for a while (had a few teething problems with early versions ;-) I've been meaning to return and try the latest).

Grizzly (comms libs) supports websockets and has a chat example it comes with the latest version of glassfish (webserver), your find chat sample blogs and even a youtube video or two if you google. (All open source). Should be support in Chrome and Firefox , can't remember the state of IE .

To be honest some of the tutorials seem to get quickly out of date as (at least a few months ago) this was a rapidly moving area you may want to wait for it to settle down a bit, depending on your level.

web socket char sample


"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 349
Yes, it's a rapidly changing situation. That's certainly a big part of the problem getting started. But I should start. I want to start. I should start as soon as possible. It seems like something simple and basic would probably last a while, and as long as I keep it simple, it won't be too much of a problem to update it should something change.

In fact though, I posted after finding HTML5 Server-Push Technologies, Part 2 because it's a year old. Thought I'd seek wisdom from the moose before jumping into something that might not work. As a beginner at this, I would have a very difficult time trying to fix it.
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 349
Since first posting, I've been building my own WebSocket server. Dreams that all this would be simple quickly passed. I am however, getting close enough to mention the word "release" as in free Beta for anyone who wants a websocket server. (Notice I'm just "mentioning" the word - I'm still at least a couple of weeks away.) It's a multi-user server that's light-weight and screamingly fast. I'll eventually add http support so no other server will be needed for delivery of web pages (WebSockets are upgraded http connections anyway). I'll also be adding HLL functionality. First thing about that is that it will simplify application. Even though I've worked consistently to maintain "light-weight" status, this whole combination has been a life's ambition and I believe developers will find it amazing for building anything from simple and direct to large scale complex, distributed, intelligent systems.

I've used the most recent version of the standard, which is the final draft version, and will probably be very close if not the same as the final standard; version 1. Browser support is still somewhat limited. So far, only Chromium, the dev version of Google Chrome, actually supports the most recent version of the standard. There is however, apparently some code in their WebKit that provides support for other browsers. I haven't tried that yet. With the browser, I've so far made the connection and pass text messages (large and small) back and forth. That's all I've discovered so far that the browser handles. I take it support for very large text "messages" would really only be used for file transfer in conjunction with HTML5 local storage capabilities. I haven't tried that yet either. Binary transfers will likely be connected to HTML5 streaming video and audio at some point, but I haven't run across any mention of it so far.

I'm currently working on a Java client that will support the full standard, including pings and binary transfers, file transfers - the whole ball of wax. Most of what I need has already been built for the server and its "echo" application which includes message sending just like a client. I will then revisit some of my earliest work to generalize in a nice way when adding the new functionality. Having one or more Java websocket clients in applications will be a good thing in many cases, I think. And it'll give the the full capabilities for web browsers as well, whenever they're ready for it.

I also know that Opera is quite popular among HTML5 enthusiasts. I actually started using the version of the standard that they support so it shouldn't be difficult to add it. (Just fooling around trying to find my way - and got the stuff specific to that version working.) I'm seriously tempted to spend the time putting the support in for that version even though it should become totally obsolete within a few months. It's just that Opera is very good on the other HTML5 stuff and there's a large crowd of enthusiasts using it. On the other hand, they mostly work on the browser-client side, and I don't know if they'll get involved much on building server-side applications.

Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 349
Update to update: Works with Firefox too, I just discovered. Firefox is using a special prefixed Object name for WebSocket - MozWebSocket - until ... something ... full final version implementation I think, maybe. So for the moment, the JavaScript in the web page needs some of that old boring web-browser identification. But it's not all that much, and I understand it's only temporary.
Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 407
    
    1

My understanding is that this is all caused by some security hole in web sockets such that the protocol was revised ?? and therefore default websocket handling was turned off from some browers and Mozllia introduced the new object to make clear this was an implementation of a new standard that wasn't ratified ie. to change it later.

I have been treading water a bit with web sockets because of this , so if some one reading this understands the situation better please post here (I'm just a casual follower of this topic);-) I was playing with Glassfish -> Grizzly web sockets and the various browsers and was stuck with some issues but this latest security issue has made me hold off on any development as I'm not sure where the various browsers and servers are now.
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 349
Now that I ran across the MozWebSocket, I remember running across it earlier. It was back when I was just starting to investigate so it had slipped out of my mind along with a lot of other things. I know there's an explanation for why they're using a prefix out there. I just don't have the photographic memory needed to be sure I'm absolutely right; but my existing memory system leans more toward thinking it had to do with waiting for final version and final interpretation of details in the protocol. In the mean time, MozWebSocket may or may not work exactly the way the standard says for it to work. But at present, it works for me - so can't say that I need the prefix.

As for the security problem, that's apparently not it. That's been fixed since version 7. The Firefox response to the discovery of the security hole was to turn WebSockets off by default. (You could turn it back on at your own risk.) Opera did the same thing. Both defaults are now on.

Here's a relevant press release: http://news.softpedia.com/news/Google-Updates-Chrome-s-WebSocket-Implementation-to-Improve-Security-214633.shtml
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 349
Just read something that suggests that Mozilla already had an object named WebSocket, and needed to use another name until they could get it sorted out.
 
jQuery in Action, 2nd edition
 
subject: WebSockets
 
Similar Threads
Struts 2, Comet & WebSockets
Tomcat 7 and HTML5 websockets support
AJAX,WebSockets, XMPP?