Just using the EchoAnnotation code

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// client code
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        if (window.location.protocol == 'http:')
        {
            // target = 'ws://' + window.location.host + '../websocket/
connect.ws';
            target = 'ws://' + window.location.host + '/inlook/websocket/
connect.ws';
        }
        else
        {
            target = 'wss://' + window.location.host + '../websocket/
connect.ws';
        }
        if ('WebSocket' in window)
        {
            ws = new WebSocket(target);
        }
        else if ('MozWebSocket' in window)
        {
            ws = new MozWebSocket(target);
        }
        else
        {
            alert('WebSocket is not supported by this browser.');
            return;
        }
        ws.onopen = function ()
        {
            console.log('onopen');
        };
        ws.onmessage = function (event)
        {
            console.log('onmessage start');
        };
        ws.onclose = function ()
        {
            console.log('onclose');
        };

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// server code
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ServerEndpoint("/websocket/echoAnnotation")
public class EchoMessage
{
@OnOpen
public void onOpen(Session session)
{
System.out.println("New connection with client");
}

@OnMessage
public void echoMessage(Session session, String msg)
{
System.out.println("echoTextMessage: " + msg);
}

@OnClose
public void onClose(Session session)
{
System.out.println("Close connection for client");
}

@OnError
public void onError(Throwable exception, Session session)
{
System.out.println("Error for client");
}

}


On Tue, Mar 4, 2014 at 2:29 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Bob,
>
> On 3/4/14, 11:16 AM, Bob Mancarella wrote:
> > Tomcat 7.0.52 on Ubuntu 14.04
> >
> > Websocket connection closes automatically after about 10 seconds.
> > The browser creates the initial connection. OnOpen is called on the
> > server. After 10 seconds OnClose is called and the connection is
> > closed. I have tried changing connectionTimeout="-1" on Connector.
> > Also tried session.setMaxIdleTimeout(-1); Neither has any effect.
>
> HttpSession has no impact on Websocket. Neither does
> connectionTimeout... that's all about HTTP connections, etc. Once you
> are in Websocket land, everything changes.
>
> Can you post some sample code -- like what your client and server code
> look like?
>
> > On my Windows 7 dev machine the connection stays up until told to
> > close. Also when I used apt-get to install Tomcat these files were
> > missing... tomcat7-wobsocket.jar and websocket-api.jar. I copied
> > them into /usr/share/tomcat7/lib which seemed to work.
>
> Please post your <Connector> configuration. Are you using APR at all?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQIcBAEBCAAGBQJTFimqAAoJEBzwKT+lPKRYnhAP/22raw7aVia8fEF9Sg9xANVV
> 0mYm/DoZWAY+xwN6TtHwiCHHXD1H0mfNXNpvcwBjVCheBPOdrrGAoJ+dg/w5BBey
> 98MaJ3aeyZ/J17wDW6ya3BgVomWkWOjDyqOtuMbOM8dZiCcOEwr/tqgQCnT5ClUH
> eqKPnZ4uRC5dx6+bpDkX2IzMZxKzPgdXV5b2n/k6ruGzarLbFCXtzyC4Jgi9wl1I
> 8a/1RwAAQSpRawEVjkHMhlzGUpHjRm/8m4HwZiVlRp6xWDn082Ag0DlcJODo5SH/
> ACOk0dH3oG/1QyRUxUWtlqMB5Be/34V8iomyo2GZAD3EvXurl8dpyc4FspU144sK
> m3hNwyYRtwbYjVplvbsCYAnVzLzY/I3FMt1Q0GFQLbs9pmY66RVVIelT/v5Dzd8s
> RS8Z0aZV6jSQIuYEfPzSmm///0TKVVKarGGpMeHzrw4wsRvkFnTCy2SvOundjqAa
> WzwCUCbFCjMPpp/mTVmU8xFFr1dkmsg1qsWz/mrk0ZK/f4ZSXP0eIK88gdi7NvXX
> lUJsntlEAmOzhBYP19G6qgicN4EQQa9qj7FWyzJg+dw7r/tWHBVp8zxCaGilv7He
> Ca2DacMamtq/fjyz5eyL9DNBZ6aEy4kk0xUWDATQAH0HdYD+/qg7iMs8gw9ASEfR
> Nt2GNqjUlcRBwLTML7bD
> =4vu+
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

Reply via email to