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

How to initialize socket with a secure connection? #71

Open
mkhoussid opened this issue Nov 29, 2023 · 0 comments
Open

How to initialize socket with a secure connection? #71

mkhoussid opened this issue Nov 29, 2023 · 0 comments

Comments

@mkhoussid
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant