-
Notifications
You must be signed in to change notification settings - Fork 64
Description
I am using two different simulators at the same time once the pusher is initialized and subscribe to a private channel it works perfectly but after one minute or more it stops listing without any trigger and sometimes I get an error and after some time it auto-reconnect what causes the problem and how I can resolve this
onError: Pong reply not received code: 4201 exception: <PusherSwift.PusherError: 0x600000d73db0>
first, it will work perfectly and after 30 or 40 seconds it stops listing for new events and does not give any state change event

but after some time I got a new console like

it automatically connects and disconnect again and again until I reset pusher

Here is my configuration code for the pusher
export const Connect = async () => {
return await pusher.init({
apiKey: PUSHER_API_KEY,
cluster: PUSHER_CLUSTER,
useTLS: false,
onConnectionStateChange,
onAuthorizer: onAuthorizer,
onError,
onEvent,
onSubscriptionSucceeded,
onSubscriptionError,
onSubscriptionCount,
onDecryptionFailure,
onMemberAdded,
onMemberRemoved,
maxReconnectionAttempts: 100,
maxReconnectGapInSeconds: 0.01,
})
}
const initPusher = async () => {
if (pusher.channels.size > 0) {
const promises: any[] = [];
pusher.channels.forEach(({channelName}) =>
promises.push(pusher.unsubscribe({channelName})),
);
await Promise.allSettled(promises);
}
try {
await Connect();
if (pusher?.connectionState !== 'CONNECTED') {
await pusher.subscribe({
channelName: `private-chatify.${current_user_id}`,
onEvent: (event: PusherEvent) => {
console.log(event.eventName, event);
if (event?.eventName === 'messaging') {
setMessages(pre => [JSON.parse(event.data)?.api_message, ...pre]);
}
},
});
await pusher.connect();
}
} catch (error) {
console.log(error);
}
};
useFocusEffect(
useCallback(() => {
initPusher();
}, []),
);@pusher/pusher-websocket-react-native": "^1.3.0"
react native : "0.72.5"
x code Version 15.2