New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heart-beat header #18

Open
dimonik opened this Issue Nov 1, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@dimonik

dimonik commented Nov 1, 2016

Does your library support heart-beat mechanism?

According to spec:

The heart-beat header is OPTIONAL. A missing heart-beat header MUST be treated the same way as a “heart-beat:0,0” header, that is: the party cannot send and does not want to receive heart-beats.

@NaikSoftware

This comment has been minimized.

Owner

NaikSoftware commented Nov 1, 2016

no.. always send 0,0

1 нояб. 2016 г. 1:47 ПП пользователь "dimonik" notifications@github.com
написал:

Does your library support heart-beat mechanism?

According to spec:

The heart-beat header is OPTIONAL. A missing heart-beat header MUST be
treated the same way as a “heart-beat:0,0” header, that is: the party
cannot send and does not want to receive heart-beats.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#18, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEBgch-94iF1zJjokDsVp7sbAFrZtnGqks5q5ya1gaJpZM4KmAuh
.

@ghost

This comment has been minimized.

ghost commented Dec 13, 2016

Does this library supports ping pong feature because the connection is no more alive after fer minutes

@steviemo

This comment has been minimized.

Contributor

steviemo commented Jul 14, 2017

Yes we are seeing this too - the stomp client closes after around 1 min. Is there a workaround for this? We are using spring as websocket server. If I use the Java-WebSocket class to create the websocket the stomp connection closes cleanly, however if we use okhttp the stomp client throws an error after 1 min of inactivity - Stomp connection error
java.lang.Exception: java.io.EOFException
at ua.naiksoftware.stomp.OkHttpConnectionProvider$1.onFailure(OkHttpConnectionProvider.java:107)
at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.java:543)

For out web client we use stomp.js (connecting) to same server and don't have any of these issues. I think a heart beat thread needs to be implemented with this library - I'll have a look next week

@steviemo

This comment has been minimized.

Contributor

steviemo commented Jul 17, 2017

OK turns out the STOMP client is being closed due to ELB - not by our spring server. A direct connection to our spring server using this client maintains a connection. I think the ELB is closing as connection is idle and this doesn't happen with using stomp.js as it has a heart beat so keeps the WS connection active.

I'll look at implementing a heartbeat for this library that can be enabled/disabled and will submit a pull request

@steviemo

This comment has been minimized.

Contributor

steviemo commented Jul 17, 2017

For other that might use this thread I was able to implement my own heart beat thread which starts in the OPENED lifecycle event and stops on ERROR or CLOSED:

private void startHeartbeat() { heartbeat = heartbeatExecutor.scheduleAtFixedRate(new Runnable() { @Override public void run() { Log.e(TAG, "SEND HEARTBEAT FROM SERVICE"); if (null != stompClient) { stompClient.send("", "h").subscribe(); } } }, 0, 25, TimeUnit.SECONDS); }
private void stopHeartbeat() { if (null != heartbeat) { heartbeat.cancel(true); heartbeat = null; } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment