Skip to content
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

Disconnect websocket from FireFly when WS from EVMConnect is disconnected #158

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions src/event-stream/event-stream.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class EventStreamSocket {
private password: string,
private handleEvents: (events: EventBatch) => void,
private handleReceipt: (receipt: EventStreamReply) => void,
private handleClose: () => void,
) {
this.init();
}
Expand All @@ -77,6 +78,7 @@ export class EventStreamSocket {
this.logger.log('Event stream websocket closed');
} else {
this.disconnectDetected = true;
this.handleClose()
this.logger.error(
`Event stream websocket disconnected, attempting to reconnect in ${RECONNECT_TIME}ms`,
);
Expand Down Expand Up @@ -357,6 +359,7 @@ export class EventStreamService {
namespace: string,
handleEvents: (events: EventBatch) => void,
handleReceipt: (receipt: EventStreamReply) => void,
handleClose: () => void,
) {
const name = eventStreamName(topic, namespace);
await this.createOrUpdateStream(newContext(), name, topic);
Expand All @@ -369,6 +372,7 @@ export class EventStreamService {
this.password,
handleEvents,
handleReceipt,
handleClose
);
}
}
6 changes: 6 additions & 0 deletions src/eventstream-proxy/eventstream-proxy.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export abstract class EventStreamProxyBase extends WebSocketEventsBase {
receipt => {
this.broadcast('receipt', <EventStreamReply>receipt);
},
() => {
// When the connection is closed to EVMConnect
// Close the connection to FireFly as well
// FireFly will resend on connection the start event for the eventstreams we need to listen to
client.close()
}
);
this.namespaceEventStreamSocket.set(namespace, eventStreamSocket);
}
Expand Down
Loading