Port-forwarding with Lima-VM and Ray app

I recently made the switch from Vagrant to Lima-VM with my Trellis setup. With Vagrant, I was using the Ray app (along with the WordPress-specific plugin) for debugging PHP, and it worked well. With Lima, I can’t get it to work.

Now if I add some Ray logging in my code, e.g. in functions.php I have ray('hello world'); I should see ‘hello world’ echoed in the app, but nothing shows up.

My limited understanding is that by default the Ray package communicates with the Ray desktop app via port 23517 in the VM.

Based off of this reference in the Lima repo, I tried creating a file at trellis/.trellis/cli.yml with the following:

portForwards:
  - guestPort: 23517

But that doesn’t seem to have had any effect; the Ray app still isn’t receiving data.

Currently my ray.php config file looks like this

<?php
return [
    /*
     * Whether data should be sent to Ray.
     */
    'enable' => true,

    /*
     * The host used to communicate with the Ray app.
     */
    'host' => '127.0.0.1',

    /*
     * The port number used to communicate with the Ray app.
     */
    'port' => 23517,

    /*
     * Absolute base path for your sites or projects in Homestead, Vagrant, Docker, or another remote development server.
     */
    'remote_path' => null,

    /*
     * Absolute base path for your sites or projects on your local computer where your IDE or code editor is running on.
     */
    'local_path' => null,

    /*
     * When this setting is enabled, the package will not try to format values sent to Ray.
     */
    'always_send_raw_values' => false,
];

With Vagrant I had the 'host' => '10.0.2.2' but I changed it to try and get it working with Lima.

Wondering what is the proper way to forward a specific port in the Lima guest so that messages can be received by an external host app?

Hi Sam ,

I’ll prefix this by saying I don’t use Ray (although, looks v. interesting), so my understanding is limited too, but…

I think this is the wrong way around. Ray app seems to open port 23517 on the 0.0.0.0 interface(s) where the app is running. This will be your host machine. Your portForwards config seems to be forwarding guest port 23517 to the host - we need the inverse.

Why not set the 'host' => '127.0.0.1' line to the Lima host interface? Lima host should be accessible via host.lima.internal

2 Likes

Thank you @talss89 , you are 100% correct!

I was misunderstanding how Ray works. There wasn’t an issue with ports - just changing the host setting from 'host => '127.0.0.1' to 'host' => 'host.lima.internal' was enough to get Ray working with Lima (in fact I had made a similar change when Ray was previously referencing Vagrant as host).

2 Likes