Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EventSource reconnect timeout (Jax-RS)

Kronos72itSep 2 2015 — edited Sep 2 2015

Hello I am discovering Jax-Rs through Jersey 2.20 .

If I understood the javascript EventSource object behave as (default) after 3 second of disconnection it try to re connect .

From my point of view it is a strange behavior because reconnection must take place just when the first connection is lost but in my case EventSource try to reconnect after Jax-Rs endpoint do :

// on server

eventOutput.close();

Then EventSource figure there is disconnection about problem but it is just a closing of streming.

No error on client :

//on client

        czmlEventSource.onError = function(e) {

            e = e || event, msg = '';

            switch( e.target.readyState ){

                // if reconnecting

                case EventSource.CONNECTING:

                    msg = 'Reconnecting…';

                    break;

                // if error was fatal

                case EventSource.CLOSED:

                    msg = 'Connection failed. Will not retry.';

                    break;

            }

            console.error("XXX "+msg);

        }

If it is true , I need to avoid this behavior otherwise every subsequent reconnection download data from beginning .

please, help !

No effect if I leveraging Jersey to disabling reconnection :

final OutboundEvent.Builder eventBuilder= new OutboundEvent.Builder();

        eventBuilder.name("czml").reconnectDelay(-1);

        eventBuilder.data(JsonObject.class,v).mediaType(MediaType.APPLICATION_JSON_TYPE);

        final OutboundEvent event = eventBuilder.build();

        e.write(event); 

Message was edited by: kronos72it to insert a statement about eventBuilder.name("czml").reconnectDelay(-1);

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 30 2015
Added on Sep 2 2015
0 comments
1,450 views