简体   繁体   中英

Error callback using echo-laravel and react

I'm trying to add a callback for a pusher:subscription_error with echo-laravel. The client is done in react. The broadcaster is Pusher and I subscribe to a channel like this:

echo.private('User.' + this.props.user.id).listen("NewMessage", (newMessage) => {
      if (newMessage.message.message_room_id === this.state.selectedMessage.id) {
        this.props.newMessageInOpenBox(newMessage);
      } else {
        this.props.newMessage(newMessage);
      }
    }
  )

Im trying to get the failed subscription callback working so i can trigger a token refresh. How would i catch the subscription error? i couldn't find anything in the docs or elsewhere.

for anyone having the same problem i found that you have to go into the channel like this

 echo.connector.pusher.channels.channels['private-' + channelName].bind('pusher:subscription_error', () => {
  alert('sub error')
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM