chatengine-io / react-chat-engine-advanced

Chat Engine's react components done the right way...
MIT License
18 stars 11 forks source link

WebSocket Connection Failed #197

Closed chan-fullstack closed 1 year ago

chan-fullstack commented 1 year ago

Hi!

Could anyone please help me fix this error? WebSocket connection to 'wss://api.chatengine.io/person_v4/?session_token=st-926f63da-6522-454c-bced-1ac5aaba8d66' failed:

Not knowledgeable about WebSockets but I think there's a problem with ChatEngines's WebSocket URL.

Current setup:

import React from 'react';

import {
  MultiChatSocket,
  useMultiChatLogic,
} from 'react-chat-engine-advanced';

const PROJECT_ID = process.env.NEXT_PUBLIC_CHAT_ENGINE_PROJECT_ID
const SECRET = process.env.NEXT_PUBLIC_CHAT_ENGINE_SECRET

export function Component({ username }) {
  const chatProps = useMultiChatLogic(
    PROJECT_ID ,
    username,
    SECRET
  );
  return (
    <>
      <MultiChatWindow {...chatProps} />
      <MultiChatSocket {...chatProps} />
    </>
  );
}

Note: There are no issues while using useSingleChatLogic hook. I think the problem comes from wss://api.chatengine.io/person_v4/?session_token.

NodeJS: 14.19.1 NextJS: 12.1.5 React: 17.0.2

Thank you so much in advance!

alamorre commented 1 year ago

Yep you're right! For a few hours there were duplicate sessions keys being generated while each one should be unique

It has been patched. You may need to reconnect once/twice more for everything to regenerate 👍

HridoyHazard commented 11 months ago

i'm facing the same issue now. can anybody tell me how to fix it??

HridoyHazard commented 11 months ago

@alamorre @chan-fullstack hi how did you guys fixed it?