channel disconnects and reconnects
tfmcunha opened this issue · 2 comments
I'm having the same issue that has been previously reported but I was unable to fix..
I'm working on an app with chat feature and when the component is mounted, the channel is disconnected and reconnects(aparently).. the same happens with every key stroke while writing a message. On the terminal, everything is working fine, except for the messages informing of the channel being unsubscribed and again subscribed.
The problem is intermitent as sometimes I receive the broadcasted data from the server, and other times nothing comes through.
//request.js
import { ActionCableProvider } from 'react-actioncable-provider';
import ActionCable from 'actioncable';
const cable = ActionCable.createConsumer("ws://localhost:3001/cable");
<ActionCableProvider cable={cable}>
<Chat request_id={this.props.request.id} selected={this.state.selected} sender_id={this.props.user_id} recipient_id={this.props.request.user_id}/>`
</ActionCableProvider>
//chat.js
<ActionCableConsumer
channel={{channel: "ConversationsChannel",
conversation: this.state.conversation_id}}
onReceived={this.handleReceived}
onDisconnected={console.log("off")}
onConnected={console.log("on")}
/>
full code @this repository
Any help will be extremly appreciated!
I realize that the problem comes from the component being re-rendered on setState.. Unfortunatetly, was unable to solve it and had to give up on react-actioncable-provider..
ended up using plain actionCable.. code can be found in the repo referenced above