Skip to content

Commit

Permalink
feat: emit error page if wssER connections fail (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
rentallect authored Jul 9, 2024
1 parent 8044af4 commit cb13a0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/channel/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import ElapsedTime from 'elapsed-time';
import sodium from 'libsodium-wrappers';
import PromiseController from 'promise-controller';
import formatMessage from 'format-message';
import { ZITI_CONSTANTS } from '../constants';

formatMessage.setup({
// locale: 'en', // what locale strings should be displayed
Expand Down Expand Up @@ -216,7 +217,15 @@ class ZitiChannel {

this._zitiContext.logger.trace(`ch.hello() ch[${this._id}] wssER[${this._edgeRouterHost}] entered`);

await this._zws.open();
try {
await this._zws.open();
} catch (e) {
// Let listeners know we failed to connect to the wssER
this._zitiContext.emit(ZITI_CONSTANTS.ZITI_EVENT_WSS_ROUTER_CONNECTION_ERROR, {
wsser: this._zws._url,
});
return;
}

this._zitiContext.logger.trace(`ch.hello() ch[${this._id}] wssER[${this._edgeRouterHost}] _zws.open completed`);

Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const ZITI_CONSTANTS =
'ZITI_EVENT_CHANNEL_CONNECT_FAIL': 'channelConnectFailEvent',
'ZITI_EVENT_NESTED_TLS_HANDSHAKE_TIMEOUT': 'nestedTLSHandshakeTimeout',
'ZITI_EVENT_NO_CONFIG_PROTOCOL_FOR_SERVICE': 'noConfigProtocolForServiceEvent',
'ZITI_EVENT_WSS_ROUTER_CONNECTION_ERROR': 'WSSEnabledEdgeRouterConnectionErrorEvent',

/**
* Name of event indicating encrypted data for a nestedTLS connection has arrived and needs decryption
Expand Down

0 comments on commit cb13a0b

Please sign in to comment.