Safari can't connect to secure laravel websocket - websocket

I'm running an app, where I use laravel-websockets, with the pusher replacement and a self created websocket instance. For SSL I used a letsencrypt certificate and the nginx reverse proxy "Same location for websockets and web contents" approach. On my nginx TLS 1.2 and 1.3 is enabled. Now on Firefox and Chrome all is working fine, but on Safari (version 14.1.2, tested on a macOS Mojave 10.14.6) I get the following error in the console:
WebSocket connection to 'wss://example.com/app/asdfasdf?protocol=7&client=js&version=7.0.3&flash=false' failed: Unexpected response code: 401
These are my echo options:
const echoOptions = {
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
wsHost: window.location.hostname,
wsPort: 80,
wssPort: 443,
forceTLS: true,
enabledTransports: ['ws', 'wss'], // <-- disable pusher api fallback
disableStats: true,
};
window.Echo = new Echo(echoOptions);
I searched a lot for any kind of similar issues, but I can't find an answer.
Any ideas or help would be awesome!

I finally figgered it out:
In the "getting started" installation section mentioned here:
https://beyondco.de/docs/laravel-websockets/getting-started/installation
They say install the latest stable version with:
composer require beyondcode/laravel-websockets
This installs version 1.12.0
To fix this issue I just removed the stable version and installed the latest beta:
composer remove beyondcode/laravel-websockets
composer require beyondcode/laravel-websockets "2.0.0-beta.36"
I had some dependencies that can't be resolved, so I needed to downgrade doctrine/dbal from version 3.1 to 2.9.
Then I backed up my old config/websocket.php and published the new one of the new package with:
cp config/websocket.php config/websocket.old.php
rm config/websocket.php
php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="config"
There I adjusted some values, e.g. allowed_origin and enable_client_messages.
Finally don't forget to kill to old websockets:serve process (if its running) by searching the process id with ps aux | grep websocket and restart the websocket with:
kill <process id>
php artisan websockets:serve
PS:
I also updated pusher/pusher-php-server to version 5.0 not 3.0 as they mentioned here and used the lates npm pusher-js package 7.0.3

Related

404 on assets when using Laravel Vite + Sail

I wanted to try out Sail on my Windows machine, however, after installing Breeze on a brand new installation of Laravel and running sail npm run dev I received a 404 in the browser for http://localhost/css/app.css and http://localhost/js/app.js when navigating to http://localhost/login on my Windows host.
Laravel Vite Plugin Version: v0.6.0
Laravel Version: v9.19
Node Version: v16.18.0
NPM Version: v8.19.2
Host operating system: Windows
Web Browser & Version: Firefox 106.0.2 (64-bit)
I am able to navigate to http://localhost:5173/ in the browser which displays the informative message, so we know that it is working. When using inspect element on the /login page the following URLs are returned as a 404: http://localhost/css/app.css & http://localhost/js/app.js.
In previous attempts I did try adding the following snippet to my vite.config.js file, however, it made no difference and the problem persisted.
server: {
hmr: {
host: 'localhost',
},
},
This is a fresh install of Docker, WSL2 and Laravel with Breeze so in theory, it should all be working, but clearly, something is awry.
The result is seeing this: https://i.imgur.com/FUZsIYh.png
If anybody could point me in the right direction I would really appreciate it!

CORS Missing Allow Origin on Laravel Echo Server with Socket.io and Redis

Hi I am getting Following error after adding on my view page of laravel application.
I am using Windows 10 .
CORS Missing Allow Origin
CORS Missing Allow Origin Error Screenshot
Following Steps will resolve "CORS Missing Allow Origin" Error for your Echo Server
STEP-1:
Add "transports: ['websocket', 'polling', 'flashsocket'] // Fix CORS error!" Code inside your Echo Server Setup File (public\js\laravel-echo-setup.js) like following code:
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001',
transports: ['websocket', 'polling', 'flashsocket'] // Fix CORS error!
});
STEP-2:
Build Your Code Using "npm run dev" command
Restart your Laravel Echo Server Using "laravel-echo-server start" command
Now check your application, You can't find a CORS error now.

Laravel websockets failed after reinstall npm

I was using Laravel websockets and it worked fine till last night I did remove **node_modules** folder and **package-lock.json** file for some reasons.
I used these commands after that:
npm install
npm run dev
I expect that everything workes like before because I removed all changes.
But know there's log message in console without any try and immediately after page load with this message:
This is my echo setting, Just for information:
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
wsHost: window.location.hostname,
wsPort: 6001,
wssPort: 6001,
disableStats: true,
encrypted: false,
enabledTransports: ['ws', 'wss']
});
UPDATE :
I did clean npm cache using npm cache clean --force and did above scenario again but there's no difference in result.
Does anyone knnow where's my mistake?
Thanks in Advance
By removing the package-lock.json file you are now using different versions of all packages (within the constraints of your package.json file). You could solve this by:
Restoring package-lock.json
Removing node_modules
Run npm install
Run npm run dev
This will install the verious which you previously had since the the lock file is used exactly for that purpose.

Laravel nova keeps throwing exception Route [nova.login] not defined

I've already posted this to https://github.com/laravel/nova-issues sadly hadn't got any love from there, so I'd like to know if anyone experienced this issue and how they resolved it.
Laravel Version: 5.7.27
Nova Version: 1.2
PHP Version: 7.2.12
Operating System and Version: MacOS 10.13.6
Browser type and version: Chrome (Latest) FireFox (Latest)
Description:
Whenever I access my nova route in /admin <-- (this is where my nova resides) I get this exception thrown from/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php line 389, throw new InvalidArgumentException("Route [{$name}] not defined."), my nova was installled correctly and currently I don't have any other existing app routes this is a fresh install of laravel and fresh install of nova.
It was working fine until I introduced the custom path.
Steps To Reproduce:
Change the 'path' => '/admin'
Run php artisan config:clear or php artisan config:cache
Check your NovaServiceProvider.php and make sure it has withAuthenticationRoutes() in the routes() function like this:
protected function routes()
{
Nova::routes()
->withAuthenticationRoutes()
->withPasswordResetRoutes()
->register();
}

Windows 10 PDOException with message 'could not find driver' Laravel 5.6.33 Wampserver 3.1.7 x86

I know there is a lot on this topic around StackOverflow, but my problem is that i have php extensions already uncommented, i have made the required changes to database.php and .env and i have declared and used the necessary environment path. The only thing i haven't done is install composer due to my proxy restrictions. I have a proxy that is over a kerberos windows AD, and for some reason nothing that used to work with proxy address, port and credentials (user and password) is working anymore, so i found this website to download php libraries and its dependencies without composerand managed to get Laravel 5.6.33 working or at least apparently, becouse when i tried to call:
C:\wamp\www\laravel> php artisan migrate:install i got the following error :Illuminate\Database\QueryException : could not find driver (SQL: create table "migrations" ("id" serial primary key not null, "migration" varchar(255) not null, "batch" integer not null))and the following Exception trace: `Exception trace:
1 PDOException::("could not find driver")
C:\wamp\www\laravel\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:68
2 PDO::__construct("pgsql:host=localhost;dbname=tienda;port=5432", "postgres", "admin123", [])
C:\wamp\www\laravel\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:68`
I have to say that i am working on windows 10 Version 10.0.17134.1 64 bits and my wamp server is 3.1.7 with php 7.2.14
Any help or pointer on this issue will be appreciated
After a lot of research and frustration, I thought on give it a try to xampp and what I found was that with xampp xampp-win32-7.3.0-0-VC15.exe installed, the correct extensions enabled in the php.ini
extension=pdo_pgsql
extension=pgsql
which in the xamp case is located at
C:\xampp\php
I set the path for xampp php in my Windows 10 Ent it is C:\xampp\php and later run the command
php C:\wamp\www\laravel> php artisan tinker
, after in the tinker console run
Psy Shell v0.9.9 (PHP 7.3.0 — cli) by Justin Hileman
>>> DB::connection()->getPdo()
And I got what I was hoping for:
=> PDO {#2863
inTransaction: false,
attributes: {
CASE: NATURAL,
ERRMODE: EXCEPTION,
PERSISTENT: false,
DRIVER_NAME: "pgsql",
SERVER_INFO: "PID: 1764; Client Encoding: UTF8; Is Superuser: on; Session Authorization: postgres; Date Style: ISO, MDY",
ORACLE_NULLS: NATURAL,
CLIENT_VERSION: "9.6.9",
SERVER_VERSION: "9.6.11",
STATEMENT_CLASS: [
"PDOStatement",
],
EMULATE_PREPARES: false,
CONNECTION_STATUS: "Connection OK; waiting to send.",
DEFAULT_FETCH_MODE: BOTH,
},
}
A response, which means that it found the driver that was always there and was able to use to access the database which was already installed and running.
The rest settings done in wamp with the virtual host and extensions enabled with the PHP version of 7.3.1 are the same and work like a charm.
I hope this may help others until the wamp and laravel teams find a way to make laravel
php artisan migrate
the command to work with wamp 3.1.7 for the x86 architecture alone.

Resources