Can not receive new messages after several mins since the first channel enter. I use sendbird v4 in a nuxt.js web project.
"@sendbird/chat": "4.0.11",
"nuxt": "2.15.8",
import SendbirdChat, {ConnectionHandler} from '@sendbird/chat'
import { OpenChannelModule, OpenChannelHandler } from '@sendbird/chat/openChannel';
import { v4 as uuid } from 'uuid';
const appId = process.env.SENDBIRD_APP_ID;
const params = {
appId: appId,
localCacheEnabled: false,
modules: [
new OpenChannelModule(),
]
}
export const sb = SendbirdChat.init(params);
export const connectionHandler = new ConnectionHandler();
export default {
connect(userId, token) {
return new Promise(async (resolve, reject) => {
sb.connect(userId, token)
.then((user) => {
sb.addConnectionHandler(userId, connectionHandler);
resolve(user);
})
.catch(error => {
reject(new Error(`Sendbird Login Failed: ${error.code} - ${error.message}`))
});
});
},
enterChannel(channelUrl, onMessageReceived, onMessageUpdated) {
sb.openChannel.getChannel(channelUrl)
.then(channel => {
channel.enter()
.then(() => {
const openChannelHandler = new OpenChannelHandler({
onMessageReceived: (channel, message) => { onMessageReceived(channel, message) },
onMessageUpdated: (channel, message) => { onMessageUpdated(channel, message) },
})
sb.openChannel.addOpenChannelHandler(uuid(), openChannelHandler);
})
.catch(error => {
console.error(`Could not enter channel ${channelUrl}: ${error.code} - ${error.message}`)
return
})
})
.catch(error => {
console.error(`Could not get channel ${channelUrl}: ${error.code} - ${error.message}`)
return
})
},
}