You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Madhur Ahuja <ah...@gmail.com> on 2015/03/29 11:17:48 UTC

Tomcat - thread dies randomly

We have built a messaging server using PubNub which listens for chat
messages from Android device.
For this, our J2EE based spring, we have created a Pubnub listener (which
is basically a listening socket)
as follows. However, we have observed is that our server stops listening
randomly after few days. The
Tomcat keeps working fine, but just the socket stops listening. There is
not error in logs.

Can anyone help in diagnosing this issue? Specifcally, I want to ensure
that the below design to initiate a listener is durable and not prone
to errors.

public class IncomingListener implements ApplicationListener <
ContextRefreshedEvent > {

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {

        private static volatile boolean isContextLoaded = false;

        @Autowired
        ServletContext application;

        synchronized(IncomingListener.class) {

            if (isContextLoaded) {
                System.out.println("WTF: Not initializing incoming
listener");
                return;
            }
            try {
                initialiseIncomingListener();
                isContextLoaded = true;
            } catch (JSONException e) {
                e.printStackTrace();
            } catch (AkoshaException e) {
                e.printStackTrace();
            }

        }
    }

    private void initialiseIncomingListener()
    {
     // Initialize our Pubnub Listener

     pubnub.subscribe(serverchannel, new Callback() {

     // Subscribe to pubnub
});
    }
}

Re: Tomcat - thread dies randomly

Posted by Marcos Almeida Azevedo <ma...@gmail.com>.
On Sun, Mar 29, 2015 at 5:17 PM, Madhur Ahuja <ah...@gmail.com>
wrote:

> We have built a messaging server using PubNub which listens for chat
> messages from Android device.
> For this, our J2EE based spring, we have created a Pubnub listener (which
> is basically a listening socket)
> as follows. However, we have observed is that our server stops listening
> randomly after few days. The
> Tomcat keeps working fine, but just the socket stops listening. There is
> not error in logs.
>
> Can anyone help in diagnosing this issue? Specifcally, I want to ensure
> that the below design to initiate a listener is durable and not prone
> to errors.
>

Seems the issue is with your application not Tomcat. Maybe try WebSocket?


>
> public class IncomingListener implements ApplicationListener <
> ContextRefreshedEvent > {
>
>     @Override
>     public void onApplicationEvent(ContextRefreshedEvent event) {
>
>         private static volatile boolean isContextLoaded = false;
>
>         @Autowired
>         ServletContext application;
>
>         synchronized(IncomingListener.class) {
>
>             if (isContextLoaded) {
>                 System.out.println("WTF: Not initializing incoming
> listener");
>                 return;
>             }
>             try {
>                 initialiseIncomingListener();
>                 isContextLoaded = true;
>             } catch (JSONException e) {
>                 e.printStackTrace();
>             } catch (AkoshaException e) {
>                 e.printStackTrace();
>             }
>
>         }
>     }
>
>     private void initialiseIncomingListener()
>     {
>      // Initialize our Pubnub Listener
>
>      pubnub.subscribe(serverchannel, new Callback() {
>
>      // Subscribe to pubnub
> });
>     }
> }
>



-- 
Marcos | I love PHP, Linux, and Java
<http://javadevnotes.com/java-string-to-double-examples>

Re: Tomcat - thread dies randomly

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Madhur,

On 3/29/15 5:17 AM, Madhur Ahuja wrote:
> We have built a messaging server using PubNub which listens for
> chat messages from Android device. For this, our J2EE based spring,
> we have created a Pubnub listener (which is basically a listening
> socket) as follows.

If you have a component that opens its own socket, then it's not
really using Tomcat for anything. Someone here might be able to help,
but it sounds like this is not really Tomcat-related.

> However, we have observed is that our server stops listening 
> randomly after few days. The Tomcat keeps working fine, but just
> the socket stops listening. There is not error in logs.

Yup, it sounds like it's not Tomcat-related. I'll let some others on
the list with more Spring-related experience jump in and try to help.

- -chris

> Can anyone help in diagnosing this issue? Specifically, I want to
> ensure that the below design to initiate a listener is durable and
> not prone to errors.
> 
> public class IncomingListener implements ApplicationListener < 
> ContextRefreshedEvent > {
> 
> @Override public void onApplicationEvent(ContextRefreshedEvent
> event) {
> 
> private static volatile boolean isContextLoaded = false;
> 
> @Autowired ServletContext application;
> 
> synchronized(IncomingListener.class) {
> 
> if (isContextLoaded) { System.out.println("WTF: Not initializing
> incoming listener"); return; } try { initialiseIncomingListener(); 
> isContextLoaded = true; } catch (JSONException e) { 
> e.printStackTrace(); } catch (AkoshaException e) { 
> e.printStackTrace(); }
> 
> } }
> 
> private void initialiseIncomingListener() { // Initialize our
> Pubnub Listener
> 
> pubnub.subscribe(serverchannel, new Callback() {
> 
> // Subscribe to pubnub }); } }
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJVGJNBAAoJEBzwKT+lPKRY7GEP/2LLZL793xUJ286K2Td4i9W2
qv8XyvWKwzYkibSWKCgoAmZ5PiWSl+v/7Q7WoWkbi54yHMqwSekN53E1aKmWk7fB
LPkhghf/uu+WFur7c/2c6GGEkZXV7q1QTtNlibSgsSEyXA6wI00JnzNxwAP3HO0Q
iB8r3C8/K8bMyqEkXgE4kyWTOjoCq7eeL36060InJeM247sn1UB16AX6SKx8b/Bi
zY6QBjIbvwnLDEqwWy72FU2iebXzNV2etVwU0L5UuFP9LiidEZ7wCg27yhmIkUDG
rqYo5pFHbNjJA8U7oi+DPB5mvIcRiX6wqxJ77pucyEvX3rR/qO6UiOxcGtCjADjs
988wS0cThVOhPzF8T73vxPeUBbnjEQr2K7tzBEOd4GK4u620qoJHoxZ8MlhsxsCb
KGD6YlKkOKR4kHO3UbINwxXkWzyuTIE2hojOqgO2DyEVSUm479XUewWYq07hWmRA
mO8d4TIv/CQzt4TnWw3XIPsjxWZ/dt1ca6D7HtBjCvMldIAvgwPFe6S/DUOrOH5p
K72VVjyW+6xaJYR/98ZAa3USA9ondRDsZuCkoI/65QID3NpdlyOGw2cnGrTg654M
QobUC4mXkKFNCxD31q2zaZ0QzJO7sq6OqVq9F/Yer7Fo/ZS0mLP6EmOHCQj2dRv7
Tn+waNzIpDM28Ax3VoD7
=BEPH
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org