Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Laravel websockets connection failed on production server #814

Unanswered
sts-ryan-holton asked this question in Q&A
Discussion options

I've got a Laravel 8 API project along with a Nuxt JS front-end that uses Laravel Echo. I'm installed the Laravel Websockets server and have everything working just fine with the Pusher replacement config:

'pusher' => [
 'driver' => 'pusher',
 'key' => env('PUSHER_APP_KEY'),
 'secret' => env('PUSHER_APP_SECRET'),
 'app_id' => env('PUSHER_APP_ID'),
 'options' => [
 'cluster' => env('PUSHER_APP_CLUSTER'),
 'encrypted' => true,
 'host' => '127.0.0.1',
 'port' => 6001,
 'scheme' => 'http'
 ],
],

It's also worth noting here that I've also tried:

'options' => [
 ...
 'port' => 6001,
 'scheme' => 'https'
],

and...

'options' => [
 ...
 'port' => 443,
 'scheme' => 'https'
],

However, when I deploy to my CentOS 8 server and start the websockets server with php artisan websockets:serve (I'm in debug mode) and I try to connect, I'm getting a connection failed error. I'm using the default port of 6001 and default host of 0.0.0.0, the error I get from my front-end is:

WebSocket connection to 'wss://127.0.0.1/app/local?protocol=7&client=js&version=7.0.3&flash=false' failed:

My front-end is for example: https://example-gui.example.com/ whilst my running API is on https://example-api.example.com/, both on the same server, and the same server as the running websockets server.

I'm using Cloudflare for HTTPs, and I'm not sure whether I need to change anything with the host?

I originally had the connection like this:

'wss://127.0.0.1/app/local?protocol=7&client=js&version=7.0.3&flash=false', when I run netstat -tulnp I do indeed see that port 6001 is in there.

What am I missing to connect in production?

I'm stuck in knowing how to get it to connect!

You must be logged in to vote

Replies: 3 comments 6 replies

Comment options

I have a smilar issue, but what's weird is it's been working just fine for months. Until we upgraded to PHP 8 yesterday, it just stopped, and am now getting a similar error with an empty exception message, re-thrown from PusherBroadcaster.php.

WebSocket connection to 'wss://api.domain.co:6001/app/UNIQUE_APP_IDENTIFIER?protocol=7&client=js&version=7.0.3&flash=false' failed:

This error is thrown from both my frontend, as well as the dashboard.

My setup uses SSL, and the user (as defined in supervisor) has read access to the fullchain cert and private key. As part of debugging, I even tried running it in debug mode as root, but the error persists. Nothing in the logs.

I've tinkered with SSL verification, on and off, but nothing makes a difference, even afterflushing config caches, restarting processes, etc.

This could still well be an environment issue, but I just don't know what it could be, as everything is setup correctly, and it worked perfectly before the upgrade.

Running Laravel 8.55, websockets 1.12 and pusher-http-php 5.0.3. My local ocnfiguration works fine, though it is of course in a Valet environment, and so it is configured slightly differently.

You must be logged in to vote
5 replies
Comment options

My configuration is as follows:

broadcasting:

[
 'driver' => 'pusher',
 'key' => env('WEBSOCKETS_APP_KEY'),
 'secret' => env('WEBSOCKETS_APP_SECRET'),
 'app_id' => env('WEBSOCKETS_APP_ID'),
 'options' => [
 'cluster' => env('WEBSOCKETS_APP_CLUSTER'), // resolves to mt1
 'encrypted' => true, // have not tried false here yet
 'host' => env('WEBSOCKETS_APP_HOST', array_values(array_filter(explode('/', env('APP_URL'))))[1]),
 'port' => 6001,
 'scheme' => 'https',
 'curl_options' => [
 CURLOPT_SSL_VERIFYHOST => (int) env('WEBSOCKETS_CURLOPT_SSL_VERIFYHOST', 2), // also tried 0
 CURLOPT_SSL_VERIFYPEER => (int) env('WEBSOCKETS_CURLOPT_SSL_VERIFYPEER', 1), // also tried 0
 ]
 ],
],

websockets:

'ssl' => [
 'local_cert' => env('WEBSOCKETS_SSL_LOCAL_CERT', null), // readable
 'local_pk' => env('WEBSOCKETS_SSL_LOCAL_PK', null), // readable
 'passphrase' => env('WEBSOCKETS_SSL_PASSPHRASE', null),
 'verify_peer' => env('WEBSOCKETS_SSL_VERIFY_PEER', true), // also tried false
]

No need for me to share frontend code here, as the dashboard also does not connect, throwing the same "Pusher error: .".

Comment options

My issue has been resolved. Turns out that the SSL certificates were moved due to a change in HTTP servers, which meant that the socket server was pointing to the incorrect symlinks.

Comment options

I also same isuue pusher.js?dc8e:4027 WebSocket connection to 'wss://127.0.0.1/app/AnyKey?protocol=7&client=js&version=7.0.6&flash=false' failed:

Comment options

You find a solution?

Comment options

Comment options

I was also facing the same issue. After contacting with hosting provider I found that my port 6001 was blocked in shared hosting. So that's why the laravel web socket is not working. Please check once if it's the same issue on your end also.

You must be logged in to vote
1 reply
Comment options

I was also facing the same issue. After contacting with hosting provider I found that my port 6001 was blocked in shared hosting. So that's why the laravel web socket is not working. Please check once if it's the same issue on your end also.

What port are you running?

Comment options

6001
...
On Tue, 2 May, 2023, 9:45 pm Ivan Novikov, ***@***.***> wrote: I was also facing the same issue. After contacting with hosting provider I found that my port 6001 was blocked in shared hosting. So that's why the laravel web socket is not working. Please check once if it's the same issue on your end also. What port are you running? — Reply to this email directly, view it on GitHub <#814 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AV44C2PWYMWHWW6PQORRG7DXEEXKTANCNFSM5CSWNIHQ> . You are receiving this because you commented.Message ID: <beyondcode/laravel-websockets/repo-discussions/814/comments/5782928@ github.com>
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #783 on July 19, 2021 10:21.

AltStyle によって変換されたページ (->オリジナル) /