Socket.IO not connecting in Chrome browser (HTTPS, custom port 6530)

Aperta
#5,343 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
20/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript, laravel, react

Direzione di ricerca

Inizia ispezionando il codice di connessione di React e la CHAT_URL configurata, quindi confronta la richiesta Chrome che non va a buon fine con l’endpoint wss://example001:6530/socket.io indicato nel deployment HTTPS. Il lavoro è completato quando il sito React si connette in Chrome senza dover aprire prima il sito Laravel, mentre il comportamento HTTP locale esistente continua a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

needs author input

Socket issue:

My Laravel backend is hosted on https://example001.com/, while my Reactapp is hosted on https://example002.com./ React uses the 4.8.1 version of the socket.io client, and Laravel uses the 4.7.5 version. What happens if I don't open website, https://example001.com/(my primary chat.js code), in Chrome so My https://example002.com/ website won't connect to the socket, breaks the socket connection, and displays a Websocket error.

What need I do to effectively run my https://example001.com/ without opening that website?..(SAFARI ,FIRE FOX RUNNING WELL)

My local (http) environment works properly, and the only problem is with the https environment.

My local (http) environment works properly, and the only problem is with the https environment.

Error :
Socket connection error---------: J: websocket error at Z.onError (https://example002.com/assets/engine.io-client-C44f3zIw.js:1:1577) at ws.onerror (https://example002.com/assets/engine.io-client-C44f3zIw.js:1:7721)

Server listing on: wss://example001:6530/socket.io/?user_id=1&user_token=eU1GUXBpbk...&user_type=admin&user_status=active&environment=production&EIO=4&transport=websocket

code:

export const handleSocketConnection = createAsyncThunk(
"socket/connectSocket",
async (data, thunkAPI) => {
const { user_id, user_type, user_token } = data;

    var options = {
        transports: ['websocket'],
        query: {
            user_id,
            user_token,
            user_type,

        },
        secure: true,
        withCredentials: false,
    };

    try {
        const socket = io(CHAT_URL, options);


        socket.on("connect", () => {
            console.log("Socket connected successfully");
            thunkAPI.dispatch(setSocketConnected(true));
        }
        );
        socket.on("connect_error", (err) => {
            console.error("Socket connection error---------:", err);
        });
        socket.on("disconnect", () => {
            console.log("Socket disconnected");
            thunkAPI.dispatch(setSocketConnected(false));
        });

        return thunkAPI.dispatch(setSocket(socket));
    } catch (error) {
        thunkAPI.dispatch(setSocketConnected(false));
        return rejectWithValue(error);
    }
}

);

Lingua principale
TypeScript
Stelle
63.2k
Fork
10.2k
Merge medio
6g 4h
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di socketio/socket.io

Tutte le issue di socketio/socket.io

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.