File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 2222 - ' --timeout=3600'
2323 - ' --max-instances=10'
2424 - ' --min-instances=0'
25- - ' --concurrency=1'
25+ - ' --concurrency=10'
26+ - ' --session-affinity'
2627 - ' --port=8080'
2728 - ' --env-vars-file=.env.yaml'
2829
Original file line number Diff line number Diff line change @@ -52,12 +52,19 @@ function coerceTypes(obj) {
5252 return coerced ;
5353}
5454
55- // Initialize Socket.IO server
55+ // Initialize Socket.IO server with Cloud Run optimizations
5656io = new Server ( httpServer , {
5757 cors : {
5858 origin : '*' , // Adjust in production for security
5959 methods : [ 'GET' , 'POST' ]
60- }
60+ } ,
61+ // Cloud Run optimizations
62+ transports : [ 'websocket' , 'polling' ] , // Allow both but prefer WebSocket
63+ allowEIO3 : true , // Allow different Engine.IO versions
64+ pingTimeout : 60000 , // 60 seconds (Cloud Run timeout)
65+ pingInterval : 25000 , // 25 seconds
66+ upgradeTimeout : 30000 , // 30 seconds for upgrade
67+ maxHttpBufferSize : 1e6 // 1MB max buffer
6168} ) ;
6269
6370io . on ( 'connection' , socket => {
Original file line number Diff line number Diff line change @@ -564,6 +564,11 @@ form.addEventListener('submit', async e => {
564564 // Connect to WebSocket (same server for Cloud Run) with user info
565565 const socket = io ( {
566566 reconnection : true ,
567+ reconnectionAttempts : 5 ,
568+ reconnectionDelay : 1000 ,
569+ timeout : 20000 ,
570+ // Force WebSocket transport for Cloud Run
571+ transports : [ 'websocket' , 'polling' ] ,
567572 auth : {
568573 user : user
569574 }
You can’t perform that action at this time.
0 commit comments