pusher / pusher/pusher-websocket-react-native
Connection lost without any trigger
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 76
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with initPusher and Connect in the configuration shown, then inspect the connection-state and error callbacks while reproducing the failure with two simulators. Check the behavior of pusher-websocket-react-native version 1.3.0 under the listed React Native and Xcode versions. Done means identifying the trigger for the lost connection and documenting a verified resolution or reproducible limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100