似乎无法连接到推杆。我已经在这些工作了几天,似乎无法连接到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::[“正在连接”,{“ transport”:“ xhr_polling”,“ url”:“ https://sockjs-4444.pusher.com:443/pusher/app/DOCKOTO_KEY?protocol=7&client=js&version=6.0.3”}]
答案 0 :(得分:1)
https://snack.expo.io/@jsfit/pusher
我已经检查了pusher在本地主机上对我来说工作正常
我认为主要原因是您的ws://test.dockoto.com:6001
您知道Laravel WebSockets的默认端口6001
,但您仍然需要打开服务器上的端口。
共享主机 ,我认为如果需要,您必须与主机提供商联系以打开端口