Re: ServerSocket from within Tapestry

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: ServerSocket from within Tapestry

Christopher
Hi team,

Just wondering whether anyone has successfully implemented a serverside
WebSocket endpoint as a Tapestry service?  The beauty of implementing it
as a Tapestry service is that I could then easily PUSH messages out from
other parts of the program, via the injected service.

The client is not a browser, but a Java desktop application running Tyrus
Standalone (Grizzly).  The problem is that when the clent app attempts to
connect, the response is a 200 not 101, suggesting the request is not
being upgraded from HTTP protocol to WS protocol.

Both serverside and clientside endpoint code appears correct.  Just trying
to work out whether the problem is with Tapestry or Tomcat.

Serverside endpoint:

    @ServerEndpoint(value = "/websocket/{port-name}/{username}", encoders
= MessageEncoder.class, decoders = MessageDecoder.class)

Clientside connection URI:

    ws://the_url.com:8080/harbour/websocket

AppModule.java contains:
    public static void contributeIgnoredPathsFilter(Configuration<String>
configuration) {
        configuration.add("/websocket");
    }

Tomcat log:

    [15/Mar/2019:14:36:41 +1300] "GET /harbour/websocket HTTP/1.1" 302 -
    [15/Mar/2019:14:36:41 +1300] "GET /harbour/signin/Error404 HTTP/1.1"
200 7181

Clientside error:

    An error occurred: java.lang.RuntimeException:
javax.websocket.DeploymentException: Handshake error.
    Caused by: javax.websocket.DeploymentException: Handshake error.
    Caused by: org.glassfish.tyrus.core.HandshakeException: Response code
was not 101: 200.

On the face of it, it appears that Tapestry is not ignoring the URI as
directed in AppModule.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away." - Antoine de Saint-Exupéry.
Reply | Threaded
Open this post in threaded view
|

Re: ServerSocket from within Tapestry

Christopher
A simple solution in the end, a retweaking of the 'IgnoredPathsFilter'...

    public static void contributeIgnoredPathsFilter(Configuration<String>
configuration) {
        configuration.add("/websocket/.*");
    }


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

"A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away." - Antoine de Saint-Exupéry.
Reply | Threaded
Open this post in threaded view
|

Re: ServerSocket from within Tapestry

Lance Java-2
You might be interested in tapestry-atmosphere and tapestry-cometd. Each
project is a tapestry wrapper for an underlying websocket implementation.
The aim of each library is to integrate websocket / push functionality into
your tapestry app without requiring any javascript. Instead you can use
annotated methods and zone-like updates in your tml.

https://github.com/uklance/tapestry-atmosphere
https://github.com/uklance/tapestry-cometd


On Wed, 20 Mar 2019, 7:53 am Christopher Dodunski, <
[hidden email]> wrote:

> A simple solution in the end, a retweaking of the 'IgnoredPathsFilter'...
>
>     public static void contributeIgnoredPathsFilter(Configuration<String>
> configuration) {
>         configuration.add("/websocket/.*");
>     }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>