【问题标题】:React native custom host pusher connection反应本机自定义主机推送器连接
【发布时间】:2020-09-19 11:45:18
【问题描述】:

似乎无法连接到推送器。这几天我一直在工作,似乎无法连接到 pusher。 6.0.3版

 import Pusher from 'pusher-js/react-native';

componentDidMount() {
    this.willFocusSubscription = this.props.navigation.addListener(
        'willFocus',
        () => {

            try {
                this.pusher = new Pusher('key', {
                    wsHost: 'host',
                    wsPort: 6001,
                    enabledTransports: ['ws'],
                    disableStats:true,
                });
                Pusher.log = (msg) => {
                    console.log('Pusher message ' + msg);
                };
            } catch (error) {
                console.log('error', error)
            }

            this.group_channel = this.pusher.subscribe('groupchat.' + session_id);
            this.pusher.connection.bind('GroupMessageSent', (data) => {
                console.log('connected', data)
            });
            this.group_channel.bind('GroupMessageSent', (data) => {
                console.log('data', data)
            });


        })
}

Pusher 消息 Pusher : : ["Connecting",{"transport":"xhr_polling","url":"https://sockjs-4444.pusher.com:443/pusher/app/DOCKOTO_KEY?protocol=7&client=js&version=6.0.3"}]

【问题讨论】:

    标签: reactjs react-native pusher pusher-js


    【解决方案1】:

    https://snack.expo.io/@jsfit/pusher

    我已经检查了推送器在本地主机上对我来说工作正常 我认为主要原因是你的 ws ws://test.dockoto.com:6001 Laravel WebSockets 默认端口6001 如您所知,但您仍然需要在服务器上打开该端口。

    共享主机我认为如果需要,您必须与您的主机提供商联系以打开端口

    EC2: https://stackoverflow.com/a/56667321/13647574

    【讨论】:

    • 你的意思是。您在本地主机中连接到 ws://test.dockoto.com:6001?
    • 没有我自己的推杆设置
    • 这就是我设置推送器所需的全部内容,对吧?只是确保我没有忘记任何设置。
    猜你喜欢
    • 1970-01-01
    • 2023-01-19
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 2018-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多