Answer the question
In order to leave comments, you need to log in
"reconnect" doesn't work in socket io, why?
on the server: "socket.io": "^4.3.1",
on the client (application): "socket.io-client": "^4.3.2"
on the client (angular admin): "ngx-socket-io ": "^4.1.0",
Server + application works fine.
The server + admin panel works, but after the connection is lost, the events stop working, reconnect, reconnection, etc. - does not happen (client code) angular:
import { Socket } from 'ngx-socket-io'
export class UsersOnlineComponent implements OnInit {
constructor(private socket: Socket) {}
activation_sockets() {
this.socket.connect();
this.socket.emit('new-user', id);
this.socket.on("reconnect", (attempt) => {
console.log('Соединение восстановлено')
});
this.socket.on("reconnect_error", (error) => {
console.log('Пытаюсь восстановить соединение')
})
}
}
import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
const config: SocketIoConfig = { url: 'http://localhost:4600/', options: {
reconnection: true
} };
Answer the question
In order to leave comments, you need to log in
It was not possible to resolve this moment. I had to downgrade to a lower version. Combination that works:
on the server: "socket.io": "^2.4.1",
on the client (app): "socket.io-client": "^2.4.0"
on the client (angular admin): " ngx-socket-io": "^3.2.0",
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question