Skip to content

Commit 834912a

Browse files
authored
Merge pull request #775 from aws-samples/development
Release 0.21.7
2 parents 16d1342 + b197afa commit 834912a

16 files changed

+152
-57
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
## [0.21.6] - 2024-09-20
7+
## [0.21.6] - 2025-01-23
8+
- Add heartbeat for streaming responses to prevent idle timeout of 10 mins
9+
10+
## [0.21.6] - 2024-12-18
811
- Updatae the Web UI to allow VPC integration with all Lambda functions. This requires your VPC to at a minimum be able to access S3, and additional optional functionality will require additional VPC endpoints to services.
912
- Package updates to address vulnerabilities.
1013

dist/lex-web-ui-loader.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lex-web-ui-loader.min.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* lex-web-ui v0.21.6
2+
* lex-web-ui v0.21.7
33
* (c) 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
* Released under the Amazon Software License.
55
*/

dist/lex-web-ui.js

+65-31
Large diffs are not rendered by default.

dist/lex-web-ui.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lex-web-ui.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lex-web-ui.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wav-worker.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wav-worker.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lex-web-ui/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lex-web-ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lex-web-ui",
3-
"version": "0.21.6",
3+
"version": "0.21.7",
44
"description": "Amazon Lex Web Interface",
55
"author": "AWS",
66
"license": "Amazon Software License",

lex-web-ui/src/store/actions.js

+37-2
Original file line numberDiff line numberDiff line change
@@ -710,11 +710,11 @@ export default {
710710

711711
wsClient.onmessage = (event) => {
712712
if(event.data!=='/stop/' && context.getters.isStartingTypingWsMessages()){
713-
console.info("streaming ", context.getters.isStartingTypingWsMessages());
713+
console.info('Streaming: ', context.getters.isStartingTypingWsMessages());
714714
context.commit('pushWebSocketMessage',event.data);
715715
context.dispatch('typingWsMessages')
716716
}else{
717-
console.info('stopping streaming');
717+
console.info('Currently not streaming');
718718
}
719719
}
720720
}
@@ -1304,6 +1304,41 @@ export default {
13041304

13051305
const signedUrl = Signer.signUrl(context.state.config.lex.streamingWebSocketEndpoint+'?sessionId='+sessionId, accessInfo, serviceInfo);
13061306
wsClient = new WebSocket(signedUrl);
1307+
1308+
// Add heartbeat logic
1309+
const HEARTBEAT_INTERVAL = 540000; // 9 minutes
1310+
const MAX_DURATION = 7200000; // 2 hours
1311+
const startTime = Date.now();
1312+
let heartbeatTimer = null;
1313+
1314+
function startHeartbeat() {
1315+
if (wsClient.readyState === WebSocket.OPEN) {
1316+
const elapsedTime = Date.now() - startTime;
1317+
if (elapsedTime < MAX_DURATION) {
1318+
const pingMessage = JSON.stringify({ action: 'ping' });
1319+
wsClient.send(pingMessage);
1320+
console.log('Sending Ping:', new Date().toISOString());
1321+
heartbeatTimer = setTimeout(startHeartbeat, HEARTBEAT_INTERVAL);
1322+
} else {
1323+
console.log('Stopped sending pings after reaching 2-hour limit.');
1324+
clearTimeout(heartbeatTimer);
1325+
}
1326+
}
1327+
}
1328+
wsClient.onopen = () => {
1329+
console.log('WebSocket Connected');
1330+
startHeartbeat();
1331+
};
1332+
1333+
wsClient.onclose = () => {
1334+
console.log('WebSocket Closed');
1335+
clearTimeout(heartbeatTimer);
1336+
};
1337+
1338+
wsClient.onerror = (error) => {
1339+
console.log('WebSocket Error', error.message);
1340+
clearTimeout(heartbeatTimer);
1341+
};
13071342
},
13081343
typingWsMessages(context){
13091344
if (context.getters.wsMessagesCurrentIndex()<context.getters.wsMessagesLength()-1){

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aws-lex-web-ui",
3-
"version": "0.21.6",
3+
"version": "0.21.7",
44
"description": "Sample Amazon Lex Web Interface",
55
"main": "dist/lex-web-ui.min.js",
66
"repository": {

templates/master.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AWSTemplateFormatVersion: 2010-09-09
22
Description: |
3-
Master Lex Web UI CloudFormation template (v0.21.6)
3+
Master Lex Web UI CloudFormation template (v0.21.7)
44
The Lex Web Ui can be deployed to operate against either a Lex V2 Bot OR a Lex V1 Bot BUT NOT BOTH.
55
Please configure either the Lex V2 bot information OR the Lex V1 bot information and leave the other
66
version input parameters as defaulted.
@@ -760,7 +760,7 @@ Resources:
760760
ShouldDeleteBot: !Ref ShouldDeleteBot
761761
ParentStackName: !Ref "AWS::StackName"
762762
SourceBucket: !Ref BootstrapBucket
763-
QBusinessLambdaCodeObject: !Sub "${BootstrapPrefix}/qbusiness-lambda-v0.21.6.zip"
763+
QBusinessLambdaCodeObject: !Sub "${BootstrapPrefix}/qbusiness-lambda-v0.21.7.zip"
764764
AmazonQAppId: !Ref AmazonQAppId
765765
IDCApplicationARN: !Ref IDCApplicationARN
766766
VpcSubnetId: !Ref VpcSubnetId
@@ -804,10 +804,10 @@ Resources:
804804
SourceBucket: !Ref BootstrapBucket
805805
SourcePrefix: !Ref BootstrapPrefix
806806
StreamingWebSocketEndpoint: !Ref StreamingWebSocketEndpoint
807-
SourceObject: !Sub "${BootstrapPrefix}/src-v0.21.6.zip"
808-
CustomResourceCodeObject: !Sub "${BootstrapPrefix}/custom-resources-v0.21.6.zip"
809-
InitiateChatLambdaCodeObject: !Sub "${BootstrapPrefix}/initiate-chat-lambda-v0.21.6.zip"
810-
StreamingLambdaCodeObject: !Sub "${BootstrapPrefix}/streaming-lambda-v0.21.6.zip"
807+
SourceObject: !Sub "${BootstrapPrefix}/src-v0.21.7.zip"
808+
CustomResourceCodeObject: !Sub "${BootstrapPrefix}/custom-resources-v0.21.7.zip"
809+
InitiateChatLambdaCodeObject: !Sub "${BootstrapPrefix}/initiate-chat-lambda-v0.21.7.zip"
810+
StreamingLambdaCodeObject: !Sub "${BootstrapPrefix}/streaming-lambda-v0.21.7.zip"
811811
CleanupBuckets: !Ref CleanupBuckets
812812
BotName:
813813
!If
@@ -904,7 +904,7 @@ Resources:
904904
UploadBucket: !Ref UploadBucket
905905
VpcSubnetId: !Ref VpcSubnetId
906906
VpcSecurityGroupId: !Ref VpcSecurityGroupId
907-
Timestamp: 1734531050
907+
Timestamp: 1737634514
908908

909909
CognitoIdentityPoolConfig:
910910
Type: AWS::CloudFormation::Stack
@@ -920,7 +920,7 @@ Resources:
920920
CognitoUserPoolClient: !GetAtt CognitoIdentityPool.Outputs.CognitoUserPoolClientId
921921
VpcSubnetId: !Ref VpcSubnetId
922922
VpcSecurityGroupId: !Ref VpcSecurityGroupId
923-
Timestamp: 1734531050
923+
Timestamp: 1737634514
924924

925925
##########################################################################
926926
# Lambda that will validate if user has put in an invalid CSS color/Hex string and fail deployment

templates/streaming-support.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,34 @@ Resources:
169169
IntegrationUri:
170170
Fn::Sub:
171171
arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${StreamingLambda.Arn}/invocations
172+
173+
PingRoute:
174+
Type: AWS::ApiGatewayV2::Route
175+
Properties:
176+
ApiId: !Ref StreamingWebSocket
177+
RouteKey: ping
178+
OperationName: PingRoute
179+
Target: !Join
180+
- '/'
181+
- - 'integrations'
182+
- !Ref PingIntegration
183+
184+
PingIntegration:
185+
Type: AWS::ApiGatewayV2::Integration
186+
Properties:
187+
ApiId: !Ref StreamingWebSocket
188+
Description: Ping Integration
189+
IntegrationType: MOCK
190+
PassthroughBehavior: WHEN_NO_MATCH
191+
RequestTemplates:
192+
application/json: '{"statusCode":200}'
193+
172194

173195
Deployment:
174196
Type: AWS::ApiGatewayV2::Deployment
175197
DependsOn:
176198
- ConnectRoute
199+
- PingRoute
177200
Properties:
178201
ApiId: !Ref StreamingWebSocket
179202

0 commit comments

Comments
 (0)