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

IOS 15.5 Cannot Connect (Client & Server 4.5.1) #4397

Open
AlvinStefanus opened this issue Jun 19, 2022 · 0 comments
Open

IOS 15.5 Cannot Connect (Client & Server 4.5.1) #4397

AlvinStefanus opened this issue Jun 19, 2022 · 0 comments

Comments

@AlvinStefanus
Copy link

AlvinStefanus commented Jun 19, 2022

Describe the bug
Cannot connect with IOS 15.5 Devices

To Reproduce

Socket.IO server version: 4.5.1

Server

export const initSocketIO = (server: any) => {
  const io = require("socket.io")(server);

  io.on("connection", async (socket: Socket) => {
    logger.info(`user is connecting...`);

    let token = socket.handshake.query.token;
    let applicationId = socket.handshake.query.applicationId;

    .....

Socket.IO client version: 4.5.1

Client

  useEffect(() => {

    if (socket) {
      socket.removeAllListeners();

      if (socket.listeners("connect").length === 0) {
        socket.on('connect', () => {
          console.log('connected')
          dispatch(setSupportStatus(true));
        })
      }

      if (socket.listeners("message").length === 0) {
        socket.on('message', (data: any) => {
          console.log(data);
          if (data.chatRoomId == support.selectedChatRoom?.id) {
            dispatch(addActiveChat(data));
          } else {
            //create notification badge
            dispatch(setNewMessage({ id: data.chatRoomId, value: true }));
          }
        })
      }

      if (socket.listeners("close-chat-room").length === 0) {
        socket.on('close-chat-room', (id: string) => {
          dispatch(closeChatRoom(id));
        })
      }

      if (socket.listeners("disconnect").length === 0) {
        socket.on('disconnect', (data: any) => {
          console.log('disconnected');
          dispatch(setSupportStatus(false));
        })
      }
    }

    if (socket && !support.connected) {
      socket.connect();
      getActiveSupportTickets();
    }
  }, [dispatch, support.connected, support.selectedChatRoom?.id, getActiveSupportTickets, socketReady]);

  useEffect(() => {
    if (support.userId && support.token && support.applicationId) {
      setSocket(io(socketIoServer,
        {
          transports: ['websocket'],
          query: {
            token: support.token,
            applicationId: support.applicationId
          }
        }));
      setSocketReady(true);
    }
  }, [support.applicationId, support.token, support.userId]);

The code does not even get into io.on("connection",..., it stopped by the error even before getting into the connection event.

Expected behavior
A clear and concise description of what you expected to happen.

I expect IOS devices to be able to connect with my server.

Platform:

  • Device: All IOS Devices 15.5
  • OS: IOS 15.5

Additional context
Add any other context about the problem here.

The Error

The error from client:

[Error] WebSocket connection to 'wss://support.xxxxxx.com/socket.io/?token=xxxxx&applicationId=xxxxxx&EIO=4&transport=websocket' failed: There was a bad response from the server.

The error from the server:

2022-06-19T04:10:44.809Z engine handshaking client "KddXP_t6guQ2dxHwAABK" 
2022-06-19T04:10:44.809Z socket.io:server incoming connection with id KddXP_t6guQ2dxHwAABK Node.js

2022-06-19T04:10:46.125Z socket.io:client no namespace joined yet, close the client 
2022-06-19T04:10:46.125Z socket.io:client forcing transport close 
2022-06-19T04:10:46.125Z socket.io:client client close with reason forced close 
2022-06-19T04:10:46.125Z socket.io:client client close with reason forced server close Node.js

2022-06-19T04:10:50.706Z engine handshaking client "Y_yOM8oTDtT8sgntAABL" 
2022-06-19T04:10:50.706Z socket.io:server incoming connection with id Y_yOM8oTDtT8sgntAABL Node.js

2022-06-19T04:10:52.615Z socket.io:client no namespace joined yet, close the client 
2022-06-19T04:10:52.615Z socket.io:client forcing transport close 
2022-06-19T04:10:52.615Z socket.io:client client close with reason forced close 
2022-06-19T04:10:52.615Z socket.io:client client close with reason forced server close

The error repeated as the client keeps trying to re-connect.

Is is fine on Android Devices


Github Repo To Test

I have setup the github repo for testing the socket.io-client using dummy user (https://github.com/AlvinStefanus/socket).


Polling Connection Works

The polling connection works fine on iOS devices, but not websocket connection.

@AlvinStefanus AlvinStefanus added the to triage Waiting to be triaged by a member of the team label Jun 19, 2022
@darrachequesne darrachequesne added needs investigation to triage Waiting to be triaged by a member of the team and removed to triage Waiting to be triaged by a member of the team labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants