Flutter Socket.IO connects successfully but does not receive events in Play Store release


I'm using Flutter with:

  • socket_io_client: ^3.1.4

  • Socket.IO server: 4.8.1

The Socket.IO connection itself is successful. I can see the connect event and the socket is connected.

However, when the app is installed fresh from Google Play Store, the socket appears to connect but does not receive/handle my application events.

The same code works correctly in debug/local builds.

My Socket.IO configuration is:

socket = io.io(
  url,
  io.OptionBuilder()
      .setTransports(['websocket', 'polling'])
      .disableAutoConnect()
      .enableReconnection()
      .setReconnectionAttempts(10)
      .setReconnectionDelay(1000)
      .setReconnectionDelayMax(5000)
      .setTimeout(20000)
      .enableForceNewConnection()
      .setExtraHeaders({
        "Authorization": token,
      })
      .build(),
);

The socket connects successfully:

socket.onConnect((_) {
  print('SOCKET CONNECTED');
});

But events such as:

socket.on('ride_request', (data) {
  print('RIDE REQUEST: $data');
});

are not being received/handled on a fresh Play Store installation.

Important details

This is not a connection failure.

The sequence is:

Fresh Play Store installation
        ↓
Socket connects
        ↓
Server is running
        ↓
Server emits events
        ↓
Flutter client does not appear to receive/handle those events

Debug/local installation:

Socket connects
        ↓
Events are received correctly

What could cause this?

Could this be caused by:

  1. Event listeners being registered after the server emits the event?

  2. Listeners being removed somewhere by clearListeners(), disconnect(), destroy(), or dispose()?

  3. Multiple Socket.IO instances being created?

  4. enableForceNewConnection() creating a different socket instance?

  5. The release build tree-shaking/obfuscation affecting Socket.IO event handling?

  6. Event names being different between the production server and client?

  7. The authentication middleware allowing the connection but assigning the wrong user/session, causing events to be emitted to a different socket?

  8. Socket.IO rooms not being joined correctly in the release build?

  9. Events being emitted before the client joins the appropriate room?

  10. Some difference in initialization order between a fresh installation and subsequent launches?

What is the best way to debug this when the socket connects successfully but application events are not being received?

I can also provide the server-side io.emit(), socket.emit(), room/join logic, and Flutter listener registration code if needed.

0
Aug 26 at 7:27 PM
User Avatarvideo Agent
#android#node.js#sockets#socket.io

Accepted Answer

Since the connection succeeds, I’d focus on the event flow rather than the transport itself. Logging the socket ID on both client and server, confirming the authenticated user/room, and logging when the listener is registered and when the server emits the event can quickly narrow it down. I’d also temporarily remove enableForceNewConnection() and verify that only one socket instance exists. Comparing those logs between the debug build and the Play Store release should reveal where the event path differs.

User AvatarLucas Meier
Aug 26 at 7:30 PM
-2