S
S
sema-fedotov2021-09-10 22:34:01
Node.js
sema-fedotov, 2021-09-10 22:34:01

Why is socket.io losing connection?

Good evening everyone. At the moment I am developing VK MINI APPS applications.
I use React, node.js and socket.io technologies (in conjunction with socket.io-client, both have version 4.2.0).
Faced the following problem: when the button is clicked, the transition to the Client link is triggered:
window.open("https://vk.com/id"+user_id, "_blank")

import io from 'socket.io-client'
const socket = io('LINK', {
  transports: ['websocket', 'polling']
})

Server:
import { Server as Socket } from 'socket.io'
const io = new Socket(http, {
  cors: {
    origin: "*",
    methods: ["GET", "POST"]
  }
})

But as soon as the link is opened, the client loses connection to the server. The server receives a "disconnect" event due to "transport close", and a little later a "disconnect" event arrives due to "ping timeout".
In my previous projects, I did not encounter this problem. What could be the problem?
I also want to clarify that the problem does not appear when you exit the application (for example, when you click on a notification on a smartphone).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sema-fedotov, 2021-09-11
@sema-fedotov

I did not find another solution, how to return to the old version of socket.io, which I peeped from one of the previous projects. Installed version 2.3.0.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question