Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverb support #61

Open
jameswagoner opened this issue Apr 20, 2024 · 12 comments
Open

Reverb support #61

jameswagoner opened this issue Apr 20, 2024 · 12 comments
Labels
enhancement New feature or request flag Flag an issue for discussion in relevant contrib meeting

Comments

@jameswagoner
Copy link

Would be nice for out of the box support for Reverb or a guide if it just needs some tweaking of the YML.

I have tried various things to get a connection going and always ends up with a connection refused error.

@reynoldsalec
Copy link
Sponsor Member

That would be awesome, I wonder if @yolcuiskender has played with Reverb at all? Know he's doing a bunch of cool stuff with Lando and various Laravel services...

@reynoldsalec reynoldsalec added enhancement New feature or request flag Flag an issue for discussion in relevant contrib meeting labels Apr 22, 2024
@yolcuiskender
Copy link
Collaborator

I haven't had the opportunity to use reverb yet, but I'm willing to give it a try in the next few days. Based on my initial understanding, I don't foresee encountering significant problems. However, if there are any specific aspects you'd like me to focus on or if you have any concerns, please feel free to let me know.

Looking forward to contributing to this issue.

@maikezan
Copy link

maikezan commented May 9, 2024

Any news about this? We are trying to set it up by ouserlves, but so far no success.
This is our current lando.yml:

name: test_app
recipe: laravel
config:
  webroot: public
  php: 8.2
  xdebug: true
  via: nginx
  database: mysql:8.0
  cache: redis
services:
  node:
    type: node:18
    scanner: false
    ports:
      - 3009:3009
  database:
    portforward: 3307
  cache:
    portforward: 32293
  appserver:
      config:
        server: .nginx/server.conf
  queue:
    type: php:8.2
    via: cli
    command: php artisan horizon
  reverb:
    type: php:8.2
    via: cli
    ssl: true
    command: php artisan reverb:start --debug
    overrides:
      ports:
        - 8080:8080
    networks:
      - network_default
networks:
  network_default:
    driver: bridge
tooling:
  npm:
    service: node
  node:
    service: node

Apparently reverb correctly starts to listen (looking at the logs) but we haven't found a way to make the app talk to the ws server. We always end up with failed connection:

WebSocket connection to 'wss://xxxxxx/app/wkvtwtt7uvf8kmmkjjgv?protocol=7&client=js&version=8.4.0-rc2&flash=false' failed: 
createWebSocket	@	pusher-js.js?v=20883fe9:3268

Following some other guide we also have configured a custom nginx.conf adding this:

.........
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;
}
........

@jameswagoner
Copy link
Author

jameswagoner commented May 9, 2024 via email

@maikezan
Copy link

Yea there is something in the network part i'm missing. Amazingly i can succesfully connect to the websocket server now from outside the application (via POSTMAN) but not from within the app container, so there must be something up there.

@reynoldsalec
Copy link
Sponsor Member

@maikezan are you using the correct hostname within the container environment for the wss server? For example, if you're trying to call the reverb service from another container in the app, it should be accessible as reverb.

@maikezan
Copy link

@maikezan are you using the correct hostname within the container environment for the wss server? For example, if you're trying to call the reverb service from another container in the app, it should be accessible as reverb.

this is something i need to test again. I think that was one of our first attempts and it didn't work. But we've made so many tests that i honestly need to rerun again with this and see if it works. Thanks for the suggestion

@maikezan
Copy link

So far no luck with using "reverb" as hostname.
We are still in this situation right now, where postman connect succesfully but laravel can't.

image

this is our current lando.yml for reverb:

reverb:
    type: php:8.3
    via: cli
    ports:
      - 8080:8080
    command: php artisan reverb:start --debug
    overrides:
      depends_on:
        cache:
          condition: service_started
        queue:
          condition: service_started

And .env file for reverb:

REVERB_APP_KEY=***
REVERB_APP_SECRET=***
REVERB_HOST="landotest.lndo.site"
REVERB_PORT=8080
REVERB_SCHEME=https```

@edouardgab
Copy link

Hi @maikezan !
Any chance you were able to resolve this? I am struggling with the same issue. Thanks !

@maikezan
Copy link

Hey @edouardgab , unfortunately i haven't resolved this. I'm currently using Laragon locally which works with some tweaks on the nginx configuration.
Basically adding this to the configuration:

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://127.0.0.1:8080;
}

I had tested this change in the lando nginx conf before, but failed to make it work. Maybe it can help you somehow?

@edouardgab
Copy link

edouardgab commented Sep 16, 2024

Hi @maikezan , Thansk for your reply !

Since my message, I was actually able to figure this out :) It was actually pretty simple once the right settings were found !

.env:

REVERB_SERVER_HOST=0.0.0.0
REVERB_SERVER_PORT=9201

REVERB_HOST=reverb
REVERB_PORT=9201
reverb:
    type: php:8.2
    via: cli
    command: php artisan reverb:start --debug
    portforward: true
    overrides:
      ports:
        - 9201:9201

I think everything you share was properly working, the issue was the necessity to properly listen to the events :

I did set it up in Postman to make it easier. Url :

First, connect to the websocket:

ws://myapp.lndo.site:9201/app/APP_ID

Then subscribe the the event

{
    "event": "pusher:subscribe",
    "data": {
        "auth": "",
        "channel": "App\\Events\\MY_EVENT"
    }
}

Hope this helps !

PS : I cannot look at the .lando.yml right now so I did by head. But it was fairly similar to what you did.

Edit : One small tip: look at the console of Reverb in Docket Desktop. That really help understanding what is going on.

@maikezan
Copy link

@edouardgab thank you for sharing your solution. I'll be giving it a try as soon as possible. i was sure we were "there" with the right approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request flag Flag an issue for discussion in relevant contrib meeting
Projects
Development

No branches or pull requests

5 participants