Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

channel disconnects and reconnects #27

Open
tfmcunha opened this issue Jun 2, 2019 · 2 comments
Open

channel disconnects and reconnects #27

tfmcunha opened this issue Jun 2, 2019 · 2 comments

Comments

@tfmcunha
Copy link

tfmcunha commented Jun 2, 2019

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!

@tfmcunha
Copy link
Author

tfmcunha commented Jun 5, 2019

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

@cseeger
Copy link

cseeger commented Jun 6, 2019

@tfmcunha - this PR (#26) should fix the problem. That said, no idea if/when it'll be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants