Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5239843
add websockets for blocks and txs
stefangutica Aug 20, 2025
6be90b6
add support for subscribe to stats
stefangutica Aug 21, 2025
1442509
use websockets rooms
stefangutica Aug 22, 2025
7d322ee
remove logs
stefangutica Aug 22, 2025
62974c7
add lock on crons
stefangutica Aug 22, 2025
8006d5e
check stats room exists
stefangutica Aug 22, 2025
d09f688
fix indent spaces
stefangutica Aug 22, 2025
62fa109
add validation pipes + filters
stefangutica Aug 22, 2025
a7e71ea
add try catch + class validator fixes
stefangutica Aug 22, 2025
58be392
fix linter
stefangutica Aug 22, 2025
cb92d2b
add pool subscription + reduce filters combinations for subscriptions
stefangutica Sep 2, 2025
344330e
lint
stefangutica Sep 2, 2025
404b18f
add support for events subscription
stefangutica Sep 2, 2025
d12208d
lint
stefangutica Sep 2, 2025
c0833a7
separate subscription websocket into separate app
stefangutica Sep 3, 2025
4f9741d
add config
stefangutica Sep 3, 2025
889a75b
add path
stefangutica Sep 3, 2025
cdfc711
fix
stefangutica Sep 3, 2025
788284b
add path for events + config default settings
stefangutica Sep 3, 2025
207ef83
temp logs
bogdan-rosianu Sep 4, 2025
524fd9e
temp logs 2
bogdan-rosianu Sep 4, 2025
e644794
added missing configs + remove temp logs
bogdan-rosianu Sep 4, 2025
c5dc598
enable andromeda in config
stefangutica Sep 4, 2025
cad49bc
add metrics on subscription
stefangutica Sep 8, 2025
8e92d63
remove async + reschedule
stefangutica Sep 8, 2025
578303a
refresh metrics every second
stefangutica Sep 8, 2025
6679b1f
set max listeners to 12
stefangutica Sep 10, 2025
703a19e
Merge branch 'development' into websockets-poc
cfaur09 Sep 16, 2025
f6f747b
add EOL
cfaur09 Sep 16, 2025
d86907f
add count on update + parallel broadcast to rooms
stefangutica Sep 25, 2025
5ceec0e
Merge branch 'development' into websockets-poc
bogdan-rosianu Oct 9, 2025
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
7 changes: 5 additions & 2 deletions config/config.devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ api:
websocket: true
cron:
cacheWarmer: true
fastWarm: true
fastWarm: false
queueWorker: true
elasticUpdater: false
flags:
Expand All @@ -20,6 +20,9 @@ flags:
processNfts: true
collectionPropertiesFromGateway: false
features:
websocketSubscription:
enabled: false
port: 6002
eventsNotifier:
enabled: false
port: 5674
Expand Down Expand Up @@ -65,7 +68,7 @@ features:
cronExpression: '*/5 * * * * *'
activationEpoch: 1043
chainAndromeda:
enabled: false
enabled: true
activationEpoch: 4
nodeEpochsLeft:
enabled: false
Expand Down
3 changes: 3 additions & 0 deletions config/config.e2e-mocked.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ api:
private: true
graphql: true
features:
websocketSubscription:
enabled: false
port: 6002
dataApi:
enabled: false
serviceUrl: 'https://data-api.multiversx.com'
Expand Down
5 changes: 4 additions & 1 deletion config/config.e2e.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ flags:
processNfts: true
collectionPropertiesFromGateway: false
features:
websocketSubscription:
enabled: false
port: 6002
eventsNotifier:
enabled: false
port: 5674
Expand Down Expand Up @@ -63,7 +66,7 @@ features:
cronExpression: '*/5 * * * * *'
activationEpoch: 1391
chainAndromeda:
enabled: false
enabled: true
activationEpoch: 4
nodeEpochsLeft:
enabled: false
Expand Down
3 changes: 3 additions & 0 deletions config/config.mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ flags:
processNfts: true
collectionPropertiesFromGateway: false
features:
websocketSubscription:
enabled: false
port: 6002
eventsNotifier:
enabled: false
port: 5674
Expand Down
5 changes: 4 additions & 1 deletion config/config.testnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ flags:
processNfts: true
collectionPropertiesFromGateway: false
features:
websocketSubscription:
enabled: false
port: 6002
eventsNotifier:
enabled: false
port: 5674
Expand Down Expand Up @@ -62,7 +65,7 @@ features:
cronExpression: '*/5 * * * * *'
activationEpoch: 1043
chainAndromeda:
enabled: false
enabled: true
activationEpoch: 4
nodeEpochsLeft:
enabled: false
Expand Down
133 changes: 133 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@
"@sendgrid/mail": "^8.1.5",
"agentkeepalive": "^4.2.1",
"amqp-connection-manager": "^4.1.3",
"anchorme": "^3.0.8",
"amqplib": "^0.10.0",
"anchorme": "^3.0.8",
"apollo-server-core": "^3.13.0",
"apollo-server-express": "3.13.0",
"bignumber.js": "^9.0.2",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.2",
"compression": "^1.8.0",
"crypto-js": "^4.1.1",
"dataloader": "^2.2.2",
Expand All @@ -144,6 +146,8 @@
"rxjs": "^7.1.0",
"sharp": "^0.34.2",
"simple-git": "^3.16.0",
"socket.io": "^4.8.1",
"socket.io-client": "^4.8.1",
"swagger-ui-express": "^4.3.0",
"tiny-async-pool": "^1.2.0",
"typeorm": "^0.3.25",
Expand Down Expand Up @@ -216,4 +220,4 @@
"node_modules"
]
}
}
}
18 changes: 18 additions & 0 deletions src/common/api-config/api.config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -954,4 +954,22 @@ export class ApiConfigService {
getCompressionChunkSize(): number {
return this.configService.get<number>('compression.chunkSize') ?? 16384;
}

getIsWebsocketSubscriptionActive(): boolean {
const isWebsocketSubscriptionActive = this.configService.get<boolean>('features.websocketSubscription.enabled');
if (isWebsocketSubscriptionActive === undefined) {
throw new Error('No features.websocketSubscription.enabled flag present');
}

return isWebsocketSubscriptionActive;
}

getWebsocketSubscriptionPort(): number {
const port = this.configService.get<number>('features.websocketSubscription.port');
if (port === undefined) {
throw new Error('No features.websocketSubscription.port present');
}

return port;
}
}
16 changes: 16 additions & 0 deletions src/common/metrics/api.metrics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class ApiMetricsService {
private static transactionsCompletedCounter: Counter<string>;
private static transactionsPendingResultsCounter: Counter<string>;
private static batchUpdatesCounter: Counter<string>;
private static subscriptionsConnectionsGauge: Gauge<string>;

constructor(
private readonly apiConfigService: ApiConfigService,
Expand All @@ -32,6 +33,13 @@ export class ApiMetricsService {
private readonly metricsService: MetricsService,
) {

if (!ApiMetricsService.subscriptionsConnectionsGauge) {
ApiMetricsService.subscriptionsConnectionsGauge = new Gauge({
name: 'websocket_subscriptions_connections',
help: 'Number of websocket connections for subscriptions',
});
}

if (!ApiMetricsService.vmQueriesHistogram) {
ApiMetricsService.vmQueriesHistogram = new Histogram({
name: 'vm_query',
Expand Down Expand Up @@ -182,6 +190,14 @@ export class ApiMetricsService {
ApiMetricsService.lastProcessedTransactionCompletedProcessorNonce.set({ shardId }, nonce);
}

@OnEvent(MetricsEvents.SetWebsocketMetrics)
setWebsocketSubscriptionsMetrics(payload: { connectedClients: number }) {
const { connectedClients } = payload;

ApiMetricsService.subscriptionsConnectionsGauge.set(connectedClients);
}


@OnEvent(MetricsEvents.SetTransactionsCompleted)
recordTransactionsCompleted(payload: { transactions: any[] }) {
ApiMetricsService.transactionsCompletedCounter.inc(payload.transactions.length);
Expand Down
Loading