Skip to content

How to initialize socket with a secure connection? #71

@mkhoussid

Description

@mkhoussid

Currently, I have the following:

// client
. . .
import { io } from 'socket.io-client';
. . .
const socket = io('https://my_domain.com', {
		reconnectionDelay: 1000,
		reconnection: true,
		reconnectionAttemps: 10,
		transports: ['websocket', 'polling', 'flashsocket'],
		agent: false,
		upgrade: true,
		secure: process.env.NODE_ENV !== 'development',
		rejectUnauthorized: false,
		query: { userId: user.id },
});
// server
. . .
import fastifySocketIo from 'fastify-socket.io';
. . .
app.register(fastifySocketIo, {
	pingInterval: 10000,
	pingTimeout: 5000,
	cookie: false,
});
. . .

Locally everything works just fine, but when NODE_ENV is set to production, a connection can't be made. What am I doing wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions