In order to setup webhooks for ARK Scan, there are several steps you need to go through. We will assume the local domain used is arkscan.test
, but adjust it where necessary.
- Run
composer install
- Run
pnpm install
- Run
php artisan reverb:install
The final installation step will setup reverb configuration. The main configuration being REVERB_APP_ID
, REVERB_APP_KEY
, and REVERB_APP_SECRET
. Below you'll find different configurations depending on whether you're using HTTP or HTTPS.
The below config values are the same regardless of which scheme you are using:
BROADCAST_DRIVER=reverb
REVERB_SERVER_HOST=0.0.0.0
REVERB_SERVER_PORT=8080
REVERB_APP_ID=123456
REVERB_APP_KEY=12345678901234567890
REVERB_APP_SECRET=12345678901234567890
REVERB_HOST="arkscan.test"
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
VITE_REVERB_PORT_TLS="${REVERB_PORT_TLS}"
APP_URL=http://arkscan.test
REVERB_SCHEME=http
REVERB_PORT=8080
Run valet secure
.
APP_URL=https://arkscan.test
REVERB_SCHEME=https
REVERB_PORT=8080
REVERB_PORT_TLS=8080
If running locally with a self-signed certificate, you will need to add the below option:
REVERB_VERIFY_PEERS=false
- Start the websocket server with
php artisan reverb:start
. You may specify different arguments to the.env
file withphp artisan reverb:start --host="0.0.0.0" --port=8080 --hostname="arkscan.test"
- In a separate window, run
pnpm dev
- Load ARK Scan and go to
arkscan.test/blocks
- In a separate window, run
php artisan horizon
- In a separate window, run
php artisan tinker
In devtools, the websocket should connected and there should be no errors.
In the tinker window, run NewBlock::dispatch()
which should trigger a reload of the Blocks table.
Once this is all setup and running correctly, you will need to then setup webhooks, which can be found here.
A short overview on what to do when setting up websockets on Forge with Laravel Reverb
- Ensure that you run PHP 8.2+
- Click the
Reverb
toggle on the site's page in Forge to enable the Reverb setup. Use port8080
and the URL on which you want the websockets to run (e.g. aws
subdomain) - Go to the SSL tab in Forge and issue a new certificate for the domain + the subdomain on which the websockets run
- Ensure
BROADCAST_DRIVER=reverb
is set in your.env
, and possibly setREVERB_PORT=443
andREVERB_SCHEME="https"
if not done automatically yet.
If there are issues connecting to the websocket when using HTTPS, you may need to connect to websockets through nginx. Use the below config to setup an nginx proxy:
Open the valet nginx config (e.g. ~/.valet/Nginx/arkscan.test
or ~/.config/valet/Nginx/arkscan.test
). Under the ssl entry, you'll need to add the following configuration. Adjust the port if necessary:
server {
listen 443;
...
location /app {
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://0.0.0.0:8080;
}
...
}
Then update your .env to reflect this:
REVERB_PORT_TLS=443
If you run into an issue where you cannot connect to a PostgreSQL database after updating to PHP 8.2, it may have to do with the swoole extension in PHP 8.2+. The error will be something along the lines of
SQLSTATE[08006] [7] could not send SSL negotiation packet: Resource temporarily unavailable (Connection: pgsql, SQL: (select * from ........)
You can get around this by removing (or renaming) the configuration file, e.g. sudo mv /etc/php/8.2/mods-available/swoole.ini /etc/php/8.2/mods-available/swoole-backup.ini