@@ -10,10 +10,8 @@ import {
1010import { Server , Socket } from 'socket.io' ;
1111
1212@WebSocketGateway ( {
13- namespace : '/camera' , // must match PUSH_NAMESPACE (default: /camera)
14- cors : { origin : '*' } , // restrict in production
15- transports : [ 'websocket' , 'polling' ] , // allow python-socketio polling handshake
16- allowEIO3 : true , // accept Engine.IO v3 clients (python-socketio compat)
13+ namespace : '/camera' , // must match PUSH_NAMESPACE (default: /camera)
14+ // cors / transports / allowEIO3 are set globally in SocketIoAdapter
1715} )
1816export class CameraGateway
1917 implements OnGatewayConnection , OnGatewayDisconnect
@@ -35,6 +33,10 @@ export class CameraGateway
3533 secret ?: string ;
3634 } ;
3735
36+ console . log (
37+ `[CameraGateway] handleConnection — id=${ client . id } deviceId=${ deviceId ?? '(none)' } transport=${ client . conn . transport . name } ` ,
38+ ) ;
39+
3840 // Only edge-gateway connections supply a deviceId.
3941 // Browser consumers connect without auth — let them through.
4042 if ( ! deviceId ) {
@@ -44,6 +46,9 @@ export class CameraGateway
4446 // Validate shared secret for gateway connections
4547 const expected = process . env . CAMERA_PUSH_SECRET ?? '' ;
4648 if ( expected && secret !== expected ) {
49+ console . warn (
50+ `[CameraGateway] rejected ${ deviceId } : secret mismatch (expected=${ expected ? '<set>' : '<empty>' } received=${ secret ? '<set>' : '<empty>' } )` ,
51+ ) ;
4752 client . disconnect ( true ) ;
4853 return ;
4954 }
@@ -55,7 +60,7 @@ export class CameraGateway
5560 this . deviceCameras . set ( deviceId , new Set ( ) ) ;
5661 }
5762
58- console . log ( `[CameraGateway] gateway connected : ${ deviceId } ` ) ;
63+ console . log ( `[CameraGateway] gateway accepted : ${ deviceId } ` ) ;
5964 }
6065
6166 handleDisconnect ( client : Socket ) {
@@ -76,8 +81,7 @@ export class CameraGateway
7681 jpeg : Buffer ; // raw JPEG bytes
7782 } ,
7883 @ConnectedSocket ( ) _client : Socket ,
79- ) {
80- const key = `${ data . deviceId } :${ data . cameraIndex } ` ;
84+ ) { const key = `${ data . deviceId } :${ data . cameraIndex } ` ;
8185 this . frames . set ( key , data . jpeg ) ;
8286
8387 // Track this camera index for the device
0 commit comments