const socket = io(config.api.socketHost, {
autoConnect: true,
reconnection: true,
timeout: 35000,
reconnectionDelay: 600,
reconnectionDelayMax: 3500,
query: {
auth: config.api.socketKey
}
})
.open();
try {
socket
.on('connect', () => {
logger.info('Connect to socket API')
})
.on('disconnect', () => {
logger.error('Disconnect to socket API')
})
.on('connect_error', (error) => {
logger.error('Error connect to socket API', error)
})
.on('connect_timeout', (error) => {
logger.error('Сonnect to socket API timeout', error)
})
.on('reconnecting', (attempt) => {
logger.warn('Error reconnecting to socket API', null, {
attempt: attempt
})
})
.on('reconnect_failed', (reconnectionAttempts) => {
logger.warn('Failed connect to socket API', null, {
reconnectionAttempts: reconnectionAttempts
})
})
.on('reconnect_error', (error) => {
logger.error('Error reconect to socket API', error)
})
} catch (error) {
logger.error('Error conect socket API', error)
}