Hi
here a small client side project [1]  I used before to put some load on the Web 
Socket implementation in Tomcat 8
It uses https type of connection simply because I was interested in SSL 
handling at that point of time. Of course you can ignore it and take a look at 
ws.echo.client.run.ClientsRunner 

1. The examples obtains reference to the container in static way
 private static final WebSocketContainer container = 
ContainerProvider.getWebSocketContainer();

2. It uses programmatic approach for getting WebSocket Session
container.connectToServer(ClientEndpoint.class, 
ClientEndpointConfig.Builder.create().build(),url)

3. adds a message handler
session.addMessageHandler(new ClientEndpointMessageHandler(latch));

4. sends a text based web socket message
session.getBasicRemote().sendText(message);

5. and closes the connection
session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE,"just close 
it"));

As you can see the maven project uses web socket implementation from Tomcat to 
establish client connection using Java SE. Basically you need the jars from the 
maven dependencies for your client code to work.

Your observation is correct, the Apache Tomcat implementation requires at least 
Java SE 7.

Hope this helps
Niki Dokovski | @nickytd 

[1] https://bitbucket.org/nickytd/websocket-echo-client


On 04.05.2014, at 17:30, Romain Manni-Bucau <rmannibu...@gmail.com> wrote:

> well I think you are not that right.
> 
> 1) client works perfectly in TomEE. Outside...well outside TomEE you
> are outside so that's fine if it doesn't work
> 2) you are right client side is needed outside a server...80% of the
> case it is javascript which is fine
> 
> You can ask Tomcat to export their client part in an importable jar
> but websocket implementation of tomcat is optimized for embedded mode.
> That said I'm +1 for it but there is no link with TomEE itself
> 
> 
> 
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
> 
> 
> 2014-05-04 16:24 GMT+02:00 Chuck Davis <cjgun...@gmail.com>:
>> Wtih all due respect, Romain, I have to take issue with your position.
>> Andy just helped me learn how to connect JSE clients to the EJB container
>> using the http protocol.  If EJB (Tomee/openEJB) is only for browser
>> clients it's quite useless for any real work.  Without Swing/JavaFX client
>> connectivity it will be consigned to such workloads as the social network.
>> It's going to be a long time before any significant data input (i.e. the
>> typical business workload) will be done with a browser interface.  It is
>> essential that JSE clients be able to connect to/use EJB via Tomee via
>> websockets.
>> 
>> In a @ClientEndpoint
>> WebsocketContainer container = ContainerProvider.getWebsocketContainer();
>> must return a container so that the container can be used to get a session
>> from the server.  Currently it throws an exception that there is no
>> implementation class.  If that is not fixed soon Tomee/openEJB  will not be
>> a welcoming project to those of us who write Java desktop applications.
>> 
>> My $.02.
>> 
>> CD
>> 
>> P.S.  By the way, connecting to the EJB container using http to find the
>> ejb seems to work nicely but it's no substitute for the advantages offered
>> by websockets.
>> 
>> 
>> 
>> 
>> On Sun, May 4, 2014 at 6:23 AM, Romain Manni-Bucau 
>> <rmannibu...@gmail.com>wrote:
>> 
>>> Well TomEE websocket implementation is to write clients from TomEE not
>>> from JavaSE (where you don't have TomEE anymore).
>>> 
>>> In TomEE clients work.
>>> 
>>> So you need to provide us a maven project with a test showing the
>>> issue you have.
>>> 
>>> 
>>> Romain Manni-Bucau
>>> Twitter: @rmannibucau
>>> Blog: http://rmannibucau.wordpress.com/
>>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>>> Github: https://github.com/rmannibucau
>>> 
>>> 
>>> 2014-05-04 15:20 GMT+02:00 Chuck Davis <cjgun...@gmail.com>:
>>>> Niki, I'm not sure what "http proxy setup for client connection" means
>>> but
>>>> it sounds suspiciously like the very piece I'm looking for -- connecting
>>> a
>>>> Java client to the server with websocket.  Is that what you are saying?
>>>> The piece WebsocketContainer container =
>>>> ContainerProvider.getWebsocketContainer() will not currently work?
>>>> Currently it returns an exception that there is no implementation class.
>>>> 
>>>> If that is so, then my contention stands that Tomee needs a better
>>>> implementation to allow Java clients to connect.
>>>> 
>>>> Thanks.
>>>> 
>>>> CD
>>>> 
>>>> 
>>>> On Sat, May 3, 2014 at 8:24 AM, Niki Dokovski <nick...@gmail.com> wrote:
>>>> 
>>>>> The only limitation in Apache Tomcat implementation of Java API for Web
>>>>> Socket (JSR 356) is the missing http proxy setup for client connections.
>>>>> This has already bean discussed in Tomcat dev lists and so far this is
>>> left
>>>>> either for future spec definitions or users demand. The rest of the
>>>>> implementation is fully functional within the JSR 356 definitions.
>>>>> 
>>>>> Best Regards
>>>>> Niki
>>>>> 
>>>>> 
>>>>> Niki Dokovski | @nickytd
>>>>> 
>>>>> 
>>> 

Reply via email to