Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

1. crash fix where socket send message when connection is not there #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/io/deepstream/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ private void tryReconnect() {
int maxReconnectInterval = options.getMaxReconnectInterval();

if( this.reconnectionAttempt < maxReconnectAttempts ) {
if(this.globalConnectivityState == GlobalConnectivityState.CONNECTED) {
if(this.globalConnectivityState == GlobalConnectivityState.DISCONNECTED) {
this.setState(ConnectionState.RECONNECTING);
this.reconnectTimeout = new Timer();
this.reconnectTimeout.schedule(new TimerTask() {
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/io/deepstream/DeepstreamClientAbstract.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ void onError(Topic topic, Event event, String msg) throws DeepstreamException {
* Help to diagnose the problem quicker by checking for
* some mon problems
*/
if( event.equals( Event.ACK_TIMEOUT ) || event.equals( Event.RESPONSE_TIMEOUT ) ) {
if( getConnectionState().equals( ConnectionState.AWAITING_AUTHENTICATION ) ) {
String errMsg = "Your message timed out because you\'re not authenticated. Have you called login()?";
onError( Topic.ERROR, Event.NOT_AUTHENTICATED, errMsg );
return;
if (event != null) {
if( event.equals( Event.ACK_TIMEOUT ) || event.equals( Event.RESPONSE_TIMEOUT ) ) {
if( getConnectionState().equals( ConnectionState.AWAITING_AUTHENTICATION ) ) {
String errMsg = "Your message timed out because you\'re not authenticated. Have you called login()?";
onError(Topic.ERROR, Event.NOT_AUTHENTICATED, errMsg);
return;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/io/deepstream/JavaEndpointWebsocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class JavaEndpointWebsocket implements Endpoint {

@Override
public void send(String message) {
this.websocket.send( message );
if (this.websocket.isOpen()) {
this.websocket.send(message);
}
}

@Override
Expand Down