Flutter socket_io_client connects but does not receive server events only in Play Store release build — how to diagnose and fix?
Background and symptom
I have a Flutter app using socket_io_client: ^3.1.4 connecting to a Socket.IO 4.8.1 server. In debug and locally installed release builds everything works: the client connects and receives server events (e.g., ride_request). On a fresh Play Store install the client shows onConnect and a socket id, but server-emitted events are not received (no onAny, no socket.on('ride_request', ...) callbacks fire). The server logs show it emits events to the expected socket id/room. This is intermittent across devices and only reproducible from Play Store installs (same APK from local install works).
What I have already checked / tried
Confirmed socket.id printed on client matches server socket.id in logs for the same connection attempt.
Added socket.onAny to detect any incoming events — nothing appears on Play Store install.
Logged socket.handshake.headers on server to confirm Authorization header present.
Temporarily removed enableForceNewConnection() — no change.
Forced transport to ['websocket'] only — no change on affected installs.
Environment
Flutter stable (AOT release)
socket_io_client: ^3.1.4
Socket.IO server: socket.io@4.8.1 (Node 18)
Android: various OEMs, tested on Pixel and Samsung
Transport options used on client: ['websocket','polling']
Client options: disableAutoConnect(), enableReconnection(), enableForceNewConnection(), setExtraHeaders({"Authorization": token}), .setTimeout(20000)
socket = io.io(url, io.OptionBuilder()
.setTransports(['websocket','polling'])
.disableAutoConnect()
.enableReconnection()
.setReconnectionAttempts(10)
.setReconnectionDelay(1000)
.setReconnectionDelayMax(5000)
.setTimeout(20000)
.enableForceNewConnection()
.setExtraHeaders({"Authorization": token})
.build());
socket.onAny((event, data) => print('onAny: $event -> $data'));
socket.on('ride_request', (data) => print('RIDE REQUEST: $data'));
socket.onConnect((_) => print('SOCKET CONNECTED id: ${socket.id}'));
socket.connect();
Server-side snippets (emits)
// on connection
io.on('connection', socket => {
console.log('connected', socket.id, socket.handshake.headers.authorization);
// later, emit to socket or room
io.to(socket.id).emit('ride_request', payload);
// or emit to room after join
socket.join('user_' + userId);
io.to('user_' + userId).emit('ride_request', payload);
});
What I have already ch