users@glassfish.java.net

Re: AW: AW: AW: Websockets with 4.0b81 - pending / half-open connections

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Sat, 06 Apr 2013 02:16:19 +0200

separate .js files are usually cached, you might need to force complete
reload of that page or somehow clear browser caches..

Pavel

On 4/5/13 10:28 PM, Bjoern Wuest wrote:
> Dear Pavel,
>
> thanks for your support. For whatever reason, when I copy the javascript
> code directly into the HTML file, web sockets do work. If I put the code in
> a separate .js-File, web sockets do not work. I think I will go with it
> having the web socket code within the HTML document.
>
> Regards
> Bjoern
>
> -----Ursprüngliche Nachricht-----
> Von: Pavel Bucek [mailto:pavel.bucek_at_oracle.com]
> Gesendet: Dienstag, 2. April 2013 16:25
> An: users_at_glassfish.java.net
> Betreff: Re: AW: AW: Websockets with 4.0b81 - pending / half-open
> connections
>
> Can you please share your application and steps you are doing? I cannot
> reproduce described behavior with our (simplelife) sample.
>
> Other than that - most browsers provide some kind of debugging support -
> intercepting HTTP headers should be present in all major ones, so you might
> want to check whether the response was received and if so, then its status
> and headers. Or you can try something like
>
> tcpdump -i lo -n -nnvvXSs 1514 port 8080
>
> (requires root)
>
> Sending the sample would still be useful, I will at least try it out and
> check whether it is working in my environment or not.
>
> Thanks,
> Pavel
>
> On 4/2/13 4:14 PM, Bjoern Wuest wrote:
>> Dear Pavel and all,
>>
>>
>> Took me quite some time to respond. As suggested I have tested the
>> code (both mine and yours) on Glassfish 4b82 (promotional build from March
> 27th).
>> I tested it on my Win7 notebook with Oracle JDK7u17 as well as a
>> Ubuntu 64bit Virtualbox machine using OpenJDK7. In both environments
>> both codes did not work, resulting in the same log and error messages as
> with 4b81 .
>> Any further hints?
>>
>>
>> Regards
>> Bjoern
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Pavel Bucek [mailto:pavel.bucek_at_oracle.com]
>> Gesendet: Mittwoch, 27. März 2013 08:46
>> An: users_at_glassfish.java.net
>> Betreff: Re: AW: Websockets with 4.0b81 - pending / half-open
>> connections
>>
>> Can you please try latest nightly?
>>
>> http://dlc.sun.com.edgesuite.net/glassfish/4.0/nightly/glassfish-4.0-b
>> 82-03_
>> 26_2013.zip
>>
>> and if it still does not work, can you provide more details about your
>> setup? (os?)
>>
>> Thanks,
>> Pavel
>>
>> On 3/27/13 7:27 AM, Bjoern Wuest wrote:
>>> Dear Pavel,
>>>
>>>
>>> I have tried your sample even I do not see much difference to my code.
>>> I tested it on Glassfish 4b81, i.e. the same Glassfish that I had run
>>> my stuff. This version is the latest Glassfish version currently
>> available.
>>> What I did is compiling and deploying the Webapp, opening in Chrome
>>> v25, clicking "Connect" button and then "Send" button.
>>>
>>> Here is the output from the server:
>>> <click Connect> Someone connected...
>>>
>>> And here from the client:
>>> <click Connect> CONNECTED to
>>> ws://localhost:8080/sample-simplelife/simplelife
>>> <click Send> Error: InvalidStateError: DOM Exception 11
>>>
>>>
>>> According to Chrome, the Websocket is still pending to be opened, i.e.
>>> receive the response from the server. Yet, the readyState of the
>>> Websocket is 1.
>>>
>>> Unfortunately I cannot install a packet sniffer like Wireshark to see
>>> if the server responds anything to the browser.
>>>
>>>
>>> Regards
>>> Bjoern
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Pavel Bucek [mailto:pavel.bucek_at_oracle.com]
>>> Gesendet: Dienstag, 26. März 2013 23:51
>>> An: users_at_glassfish.java.net
>>> Betreff: Re: Websockets with 4.0b81 - pending / half-open connections
>>>
>>> Hi Bjoern,
>>>
>>> can you please try running Tyrus sample? For example this one:
>>>
>>> http://java.net/projects/tyrus/sources/source-code-repository/show/tr
>>> u
>>> nk/sam
>>> ples/simplelife?rev=549
>>> (includes simple js client)
>>>
>>> should do what you want. (you might need to use newer glassfish
>>> build, there was new release of websocket-api in the meantime).
>>>
>>> Also, you can use users_at_tyrus.java.net mailing list.
>>>
>>> Regards,
>>> Pavel
>>>
>>> On 3/26/13 9:22 PM, bjoern.wuest_at_gmx.net wrote:
>>>> Good evening,
>>>>
>>>>
>>>> I am trying html5 websocket technology with Glassfish. I use the
>>>> Glassfish 4 b81 with JSR-356 support built-in. Yet, I fail to
>>>> actually really open a websocket. In google Chrome, it says that the
>>>> websocket connection is pending. When I try to send something from
>>>> the browser to the server via the websocket, I will get
>>>> invalidDOMException with code 11. Sending something from the server
>>>> to the client does not result in any exception (or even log message)
>>>> but message is never received at the browser.
>>>>
>>>>
>>>> Here is my server-side code:
>>>>
>>>> @ServerEndpoint(value="/ws") public class CWSHandler {
>>>> @OnOpen public void open(Session S) {
>>>> System.out.println("### NEW CONNECTION OPENED ###");
>>>> }
>>>>
>>>> @OnMessage public void process(ByteBuffer Data, Session S) {
>>>> System.out.println("### GOT MESSAGE ###");
>>>> }
>>>>
>>>> @OnError public void error(Session S, Throwable Cause) {
>>>> System.out.println("### HAVE ERROR ###");
>>>> if (null != Cause) { Cause.printStackTrace(); }
>>>> }
>>>>
>>>> @OnClose public void close(Session S, CloseReason Reason) {
>>>> System.out.println("### CONNECTION CLOSED ### " +
>>>> Reason.getReasonPhrase());
>>>> }
>>>> }
>>>>
>>>>
>>>> And here is the client code:
>>>>
>>>> var commChannel = new WebSocket(wsURI); commChannel.onerror =
>>>> function
>>>> (evt) { console.log("Error: " + evt); }; commChannel.onopen =
>>>> function
>>>> (evt) {
>>>> console.log("Connection opened: " + evt);
>>>> try { commChannel.send("Hello world"); }
>>>> catch (err) { console.log(err); }
>>>> };
>>>> commChannel.onclose = function (evt) { console.log("Connection closed:
>>>> " + evt); };
>>>> commChannel.onmessage = function (evt) { console.log("Received
>>>> message from websocket: " + evt); };
>>>>
>>>>
>>>>
>>>> The output on the server is:
>>>>
>>>> [2013-03-26T20:23:34.949+0100] [glassfish 4.0] [INFO] [] [] [tid:
>>>> _ThreadID=30 _ThreadName=Thread-3] [timeMillis: 1364325814949]
>>>> [levelValue: 800] [[
>>>> ### NEW CONNECTION OPENED ###]]
>>>>
>>>>
>>>> The output on the client is:
>>>> Connection opened: [object Event] line 4
>>>> Error: InvalidStateError: DOM Exception 11 line 6
>>>>
>>>>
>>>>
>>>> What am I missing?
>>>>
>>>> Regards
>>>> Bjoern
>>>>
>>
>