1

推送日志 似乎无法连接到推送器。这几天我一直在工作,似乎无法连接到 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 "}]

4

1 回答 1

1

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

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

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

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

于 2020-06-16T00:39:22.530 回答