nahid / talk-example

This project is demo for Laravel-Talk package and its also Docker ready
http://github.com/nahid/talk
131 stars 77 forks source link

Pusher Error. #10

Closed FooleanBool closed 7 years ago

FooleanBool commented 7 years ago

Thanks for this package, I have installed successfully, but cannot get live messaging working.

the relevant lines in .env:

PUSHER_APP_ID=3***12
PUSHER_KEY=d5f******5f693471e49
PUSHER_SECRET=875e******2f4c003408

[reals creds are correct, these changed for security]

the relevant lines in talk.php (this file is not in app/ as stated, but in config/

'user' => [
        'model' => 'App\User'
    ],
    'broadcast' => [
        'enable' => true,
        'app_name' => 'talktest-development',
        'pusher' => [
            'app_id'        => env('PUSHER_APP_ID'),
            'app_key'       => env('PUSHER_KEY'),
            'app_secret'    => env('PUSHER_SECRET'),
            'options' => [
                 'cluster' => 'eu',
                 'encrypted' => true
            ]
        ]
    ]

The result; no matter what I do, I always get the same pusher error regarding the cluister. I have set it to EU in the pusher app, and using the provided code on the debugging tab I have successfully sent test messages using only the composer require. The error message in the console:

Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":4001,"message":"Did you forget to specify the cluster when creating the Pusher instance? App key d5f*****5f693471e49 does not exist in this cluster."}}}

I've tried creating new apps, putting them in the us cluster with no change at all. It behaves as if the cluster option is not being properly supplied? (maybe ^^)

Would appreciate any guidance anyone can give :) Thanks.

nahid commented 7 years ago

which version of Talk are you using? @zigstum

FooleanBool commented 7 years ago

I cloned and setup the talk-example directory, then did composer update/install. How would I find out which specific version the example uses?

EDIT: Looking at the changelog in vendor dir, i guess it is version 1.1.4: Version :1.1.4

nahid commented 7 years ago

Please update with v2.2.0, I think it will be solved

FooleanBool commented 7 years ago

Unfortunately, no difference. My composer.json:

        "nahid/talk": "^2.2",
        "vinkla/pusher": "^2.4",
        "pusher/pusher-php-server": "^2.6",
        "predis/predis": "^1.1"

The first load gives the following console error twice: WebSocket connection to 'wss://ws.pusherapp.com/app/d5f9092bf5f693471e49?protocol=7&client=js&version=3.2.4&flash=false' failed: Invalid frame header

The followed by:

Pusher : Connecting : {"transport":"ws","url":"wss://ws.pusherapp.com:443/app/d5f9092bf5f693471e49?protocol=7&client=js&version=3.2.4&flash=false"}
3:1 WebSocket connection to 'wss://ws.pusherapp.com/app/d5f9092bf5f693471e49?protocol=7&client=js&version=3.2.4&flash=false' failed: WebSocket is closed before the connection is established.
pusher.min.js:8 Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":1006}}}
pusher.min.js:8 Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":1006}}}
pusher.min.js:8 Pusher : Connecting : {"transport":"xhr_streaming","url":"https://sockjs.pusher.com:443/pusher/app/d5f9092bf5f693471e49?protocol=7&client=js&version=3.2.4"}
pusher.min.js:8 Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":4001,"message":"Did you forget to specify the cluster when creating the Pusher instance?  App key d5f9092bf5f693471e49 does not exist in this cluster."}}}
pusher.min.js:8 Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":4001,"message":"Did you forget to specify the cluster when creating the Pusher instance?  App key d5f9092bf5f693471e49 does not exist in this cluster."}}}

Thanks for your help :)

FooleanBool commented 7 years ago

More info: Looking in debug tab in pusher.com, when sending a message using talk example app, the console shows that the message is received:

{
  "message": "uhuh",
  "conversation_id": 5,
  "user_id": 1,
  "is_seen": 0,
  "updated_at": "2017-05-03 12:05:07",
  "created_at": "2017-05-03 12:05:07",
  "id": 22,
  "conversation": {
    "id": 5,
    "user_one": 1,
    "user_two": 7,
    "status": 1,
    "created_at": "2017-05-03 11:33:12",
    "updated_at": "2017-05-03 12:05:07"
  },
  "sender": {
    "id": 1,
    "name": "Nahid Bin Azhar",
    "email": "talk@example.com",
    "created_at": "2017-05-03 09:13:35",
    "updated_at": "2017-05-03 09:30:15"
  }
}

Am i wrong to expect this message to appear in the other chat box automatically? I have two different users logged in, one on FF and one on Chrome, they are in a 'live' conversation. I don't know if it is relevant, but when I navigate to /tests I get the following error: Call to undefined method Nahid\Talk\Talk::channel()

FooleanBool commented 7 years ago

Even more info ^^

It seems that each sent message makes two calls identical calls to the pusher API.

Channel: talktest-development-conversation-4, Event: talk-send-message
12:32:31

Followed by:

Channel: talktest-development-user-8, Event: talk-send-message
12:32:31

Contents of both event are the same (as above).

FooleanBool commented 7 years ago

I have installed and run the package on my webserver, just in case it was an issue with my locl firewall, but the behaviour is exactly the same. Thanks for your help.

waseemsafder commented 7 years ago

@zigstum Basically that's the problem of the not specifying the cluster. Please made the changes in the following file /nahid/talk/src/views/pusherjs.blade.php After the parameter encrypted: true, Add cluster: 'ap2' (Check your cluster name on Pusher.com) I hope this will solve your problem.

nahid commented 7 years ago

this problem was solved. Please update Talk package and talk configuration file. Then set your credentials. I think this will work fine.

FooleanBool commented 7 years ago

@waseemsafder Thanks man :) As soon as I added that in the file you specified, the errors went and the connection is good:

Pusher : Event recd : {"event":"pusher_internal:subscription_succeeded","data":{},"channel":"talkex-js-lara-user-4"}

@nahid thanks for all the time and effort you put into this package, I did follow your advice but unfortunately it didn't solve the problem I was having.

nahid commented 7 years ago

Please Install Talk dev-master version

waseemsafder commented 7 years ago

@nahid Do you have chat with attachments? What you recommend, if I need to integrate attachments with the chat?

nahid commented 7 years ago

@waseemsafder we working on it. Maybe in next release, we will add these feature

chikeozulumba commented 7 years ago

If you are using Laravel Echo and pusher-js (i.e. Laravel 5.5^), you'll need to add the cluster option for it to work, in your bootstrap.js file for example: window.Echo = new Echo({ broadcaster: 'pusher', key: '*********************', cluster: 'eu' });

Giangnv2014 commented 6 years ago

@codeNigga Thanks man! It worked

danishuet commented 6 years ago

@codeNigga I am using pusher API to send message between two users i am new to laravel and vu js my messages are sending and receiving but i need to refresh the page for checking new message how to solve it .

marslan2037 commented 6 years ago

@waseemsafder i have exactly same problem but i did not have matching word encypted in that file, maybe new version change it but i have same problem

marslan2037 commented 6 years ago

@nahid i have this problem, please help me to solve this mention by @zigstum

nahid commented 6 years ago

Did you familiar with Docker? please try this project with docker. I think all problem will be solved. Docker contains all dependencies for this project. If you have already installed docker, just run this command form your project root and enjoy

./talk ready
marslan2037 commented 6 years ago

this command just create env file and nothing else

marslan2037 commented 6 years ago

i have installed docker, i need to configure it anywhere ?

marslan2037 commented 6 years ago

1) Download latest zip file, 2) run command ./talk ready 3) composer install 4) add pusher credentials 5) php artisan migrate 6) create account 7) click on message button and it gives error

Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":4001,"message":"Did you forget to specify the cluster when creating the Pusher instance? App key ff002e63cfa0ec7812c0 does not exist in this cluster."}}}

nahid commented 6 years ago

May be you are add wrong cluster.

BTW, you didn't need to run 3 and 5 number command. ./talk ready will automatically run this command and also install all dependancies for this project like

marslan2037 commented 6 years ago

@nahid your doc did not tell us about this :( and cluster is fine

marslan2037 commented 6 years ago

How i can configure these? Docker, Nginx, Redis all these are installed

marslan2037 commented 6 years ago

this is what it does when i run ./talk ready command , https://imgur.com/a/dhXlsgw ,nothing else