Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React native ios crashes on production with extraHeaders #1593

Open
ouarrtaha opened this issue Oct 24, 2023 · 4 comments
Open

React native ios crashes on production with extraHeaders #1593

ouarrtaha opened this issue Oct 24, 2023 · 4 comments
Labels
needs investigation This issue needs further investigations

Comments

@ouarrtaha
Copy link

ouarrtaha commented Oct 24, 2023

I need to pass a cookie, for the ingress session affinity, in order to maintain connection in multi pods,
so i set the extraHeaders:

when running the app in debug (in simulator or device) it works as expected, but after releasing ios app in testflight and testing, it crashes,

 Fatal Exception: NSInvalidArgumentException
-[__NSArrayM length]: unrecognized selector sent to instance 0x283dcfde0

To Reproduce

Socket.IO server version: 4.4.0

Server

const io = new Socket(server, {
    transports: ['websocket', 'polling'],
    cors: {
      origin: '*',
      methods: ['GET', 'POST'],
      credentials: true,
    },
    adapter: redisAdapter({
      pubClient: redisClient,
      subClient: redisClient.duplicate(),
    }),
  });

Socket.IO client version: 4.7.2

Client

initSocket(userId, cookie) {
    this.socket = io(SOCKET_URL, {
      query: `userId=${userId}`,
      autoConnect: false,
      transport: ['polling', 'websocket'],
      extraHeaders: {
        'Cookie': cookie,
      },
    });
  }
 

Expected behavior
Connect without crash and maintain connection

Platform:

  • Device: iphone 11
  • OS: ios 17
@ouarrtaha ouarrtaha added the to triage Waiting to be triaged by a member of the team label Oct 24, 2023
@ouarrtaha
Copy link
Author

Update:

it worked with

transportOptions: {
    polling: {
      extraHeaders: {
        'Cookie': cookie,
      },
    },
  }

@darrachequesne
Copy link
Member

Hi! Thanks for the report 👍

The only difference between extraHeaders: { ... } and transportOptions: { polling: { extraHeaders }}} is that, in the first case, the extraHeaders is also used when establishing the WebSocket connection.

Source: https://github.com/socketio/engine.io-client/blob/3dcb88cb31a67d19807e70b16203a9a3cf8c129d/lib/transports/websocket.ts#L70-L72

Which React Native should support I think.

Reference: https://reactnative.dev/docs/network#websocket-support

Which version of React Native are you using?

@darrachequesne darrachequesne added needs investigation This issue needs further investigations and removed to triage Waiting to be triaged by a member of the team labels Oct 25, 2023
@ouarrtaha
Copy link
Author

i'm using react native 0.72.6

@darrachequesne
Copy link
Member

@ouarrtaha I was not able to reproduce. Were you able to find the culprit? Is it fixed in newer React native versions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This issue needs further investigations
Projects
None yet
Development

No branches or pull requests

2 participants