laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.78k stars 296 forks source link

RoadRunner can't communicate with the worker #876

Closed seth-shi closed 6 months ago

seth-shi commented 7 months ago

Octane Version

2.3

Laravel Version

10.10

PHP Version

8.1

What server type are you using?

Roadrunner

Server Version

1.4.2

Database Driver & Version

No response

Description

when http request laravel, console show: RoadRunner can't communicate with the worker

Steps To Reproduce

php artisan octane:start --host=0.0.0.0 --workers=8

curl 127.0.0.1:8000/

// console ouput:
 RoadRunner can't communicate with the worker
driesvints commented 7 months ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!

mostafaznv commented 7 months ago

Hello, I recently encountered with this error after deploying some code to the server. Everything was functioning correctly until today, but now I'm facing this issue.

Akecel commented 6 months ago

I am encountering the same error after migrating to Laravel 11. I have found all the posts that @seth-shi have been made on the different channels proposed by @driesvints but he have received no response regarding this problem. Anyone have any idea what is causing this ? :/

seth-shi commented 6 months ago

@mostafaznv @Akecel image https://www.shiguopeng.cn/posts/2024042811/?#h5

driesvints commented 6 months ago

Did you mean that there was an incorrect log channel configured @seth-shi ?

seth-shi commented 6 months ago

Did you mean that there was an incorrect log channel configured @seth-shi ?您的意思是配置了不正确的日志通道吗?

yes, config/logging use stdout, rr.yaml also use stdout

Akecel commented 6 months ago

For my part, I don't have a .rr.yaml (well, it's empty, as is the default when using octane). When I use the sail artisan octane:status command I get INFO Octane server is running. but as soon as I make a request to my API I get this message in my container logs: RoadRunner can't communicate with the worker.

I'm in the middle of migrating to Laravel 11, so I don't know if that's where it's coming from.

Octane Version : v2.3.9 Laravel Version : v11.6.0 PHP Version : 8.3 Roadrunner : v2024.1.1 Roadrunner CLI : v2.6.0 Roadrunner HTTP : v3.5.1 Roadrunner Worker : v3.5.0

seth-shi commented 6 months ago

copy my content write to .rr.yaml, show error log

version: '3'
rpc:
  listen: 'tcp://127.0.0.1:6001'
server:
  command: ""
  relay: pipes
http:
  middleware: [ "static", "gzip", "headers" ]
  max_request_size: 20
  access_logs: false
  static:
    dir: "public"
    forbid: [ ".php", ".htaccess" ]
  uploads:
    forbid: [".php", ".exe", ".bat", ".sh"]
  address: "0.0.0.0:2114"
  pool:
    allocate_timeout: 10s
    destroy_timeout: 10s
    supervisor:
      max_worker_memory: 256
      exec_ttl: 60s
## 这里注意如果要输出标准输出必须在 channels 才会写 stdout
logs:
  mode: production
  level: debug
  encoding: console
  output: stderr
  err_output: stderr
  channels:
    http:
      mode: production
      level: panic
      encoding: console
      output: stdout
      err_output: stderr
    server:
      mode: production
      level: info
      encoding: json
      output: stdout
      err_output: stdout
    rpc:
      mode: production
      level: debug
      encoding: console
      output: stderr
      err_output: stdout
status:
  address: localhost:2114
Akecel commented 6 months ago

No change, only "RoadRunner can't communicate with the worker" in container log

I don't think it's to do with the rr.yaml, by default the octane one is empty and that doesn't change anything for me.

seth-shi commented 6 months ago

No change, only "RoadRunner can't communicate with the worker" in container log

I don't think it's to do with the rr.yaml, by default the octane one is empty and that doesn't change anything for me.

this config show detail log, show me your logging.php content and .rr.yaml content

Akecel commented 6 months ago

No change, only "RoadRunner can't communicate with the worker" in container log I don't think it's to do with the rr.yaml, by default the octane one is empty and that doesn't change anything for me.

this config show detail log, show me your logging.php content and .rr.yaml content

I use Laravell 11 with octane by default. I don't have a logging.php file (Laravel 11 no longer has a configuration file unless I've customised it, which I haven't) and using octane as the default means that the rr.yaml is empty, there's nothing in it

seth-shi commented 6 months ago

no, laravel's log and roadrunner' log different

Akecel commented 6 months ago

I don't understand what you're getting at ahah, you ask me for my Laravel logging file, I simply reply that I don't have one. The same goes for the rr.yaml file, which is empty by default with Laravel octane. Yet I've got the error, it must be coming from somewhere and I don't think it's simply linked to logging as I don't have any customisation at that level? I tried to modify rr.yaml with yours, no difference, I have nothing in the roadrunner logs apart from the error and nothing in my laravel logs either (I don't even have a laravel.log file in my logs) :/

seth-shi commented 6 months ago

because it is roadrunner log, so laravel.log is empty, you need update .rr.yaml log show detail

Akecel commented 6 months ago

I'm sorry, but I don't understand how my rr.yaml would have any impact here. I've been using octane for years with no problems, if migrating to Laravel 11 creates a breacking change, does that need to be documented?

Here's the example of our old rr.yaml, I don't understand what this has to do with whether or not roadrunner can communicate with the worker, honestly. Tell me what I should do with it?

version: '3'
rpc:
    listen: 'tcp://127.0.0.1:6001'
server:
    command: 'php app.php'
    relay: pipes
http:
    address: '0.0.0.0:8080'
    middleware:
        - gzip
        - static
    static:
        dir: public
        forbid:
            - .php
            - .htaccess
    pool:
        num_workers: 1
        supervisor:
            max_worker_memory: 100
jobs:
    pool:
        num_workers: 2
        max_worker_memory: 100
    consume: {  }
kv:
    local:
        driver: memory
        config:
            interval: 60
metrics:
    address: '127.0.0.1:2112'

This worked very well until recently on Laravel 11 and nowhere in the Octane documentation is there any mention of rr.yaml or its customisation. :/

seth-shi commented 6 months ago
## 这里注意如果要输出标准输出必须在 channels 才会写 stdout
logs:
  mode: production
  level: debug
  encoding: console
  output: stderr
  err_output: stderr
  channels:
    http:
      mode: production
      level: panic
      encoding: console
      output: stdout
      err_output: stderr
    server:
      mode: production
      level: info
      encoding: json
      output: stdout
      err_output: stdout
    rpc:
      mode: production
      level: debug
      encoding: console
      output: stderr
      err_output: stdout

version: '3'
rpc:
    listen: 'tcp://127.0.0.1:6001'
server:
    command: 'php app.php'
    relay: pipes
http:
    address: '0.0.0.0:8080'
    middleware:
        - gzip
        - static
    static:
        dir: public
        forbid:
            - .php
            - .htaccess
    pool:
        num_workers: 1
        supervisor:
            max_worker_memory: 100
jobs:
    pool:
        num_workers: 2
        max_worker_memory: 100
    consume: {  }
kv:
    local:
        driver: memory
        config:
            interval: 60
metrics:
    address: '127.0.0.1:2112'

## add logs config, show detail log
logs:
  mode: production
  level: debug
  encoding: console
  output: stderr
  err_output: stderr
  channels:
    http:
      mode: production
      level: panic
      encoding: console
      output: stdout
      err_output: stderr
    server:
      mode: production
      level: info
      encoding: json
      output: stdout
      err_output: stdout
    rpc:
      mode: production
      level: debug
      encoding: console
      output: stderr
      err_output: stdout
Akecel commented 6 months ago

I had to remove the log for rpc, as I had an additional error:

   ERROR  1715002997664363263   debug   rpc     plugin was started      {"address": "tcp://0.0.0.0:6001", "list of the plugins with RPC methods:": ["resetter", "app", "informer", "lock", "kv", "metrics", "jobs"]}

But after removing it, I get this error when I run octane, so it's the initial error that causes everything else?

   Illuminate\Contracts\Container\BindingResolutionException 

  Target class [config] does not exist.

  at vendor/laravel/framework/src/Illuminate/Container/Container.php:906
    902▕ 
    903▕         try {
    904▕             $reflector = new ReflectionClass($concrete);
    905▕         } catch (ReflectionException $e) {
  ➜ 906▕             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    907▕         }
    908▕ 
    909▕         // If the type is not instantiable, the developer is attempting to resolve
    910▕         // an abstract type such as an Interface or Abstract Class and there is

2024-05-06 13:44:45,698 INFO exited: php (exit status 1; not expected)
2024-05-06 13:44:46,705 INFO spawned: 'php' with pid 131
2024-05-06 13:44:47,709 INFO success: php entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
seth-shi commented 6 months ago

yes, we need change .rr.yaml config to show laravel error

Akecel commented 6 months ago

yes, we need change .rr.yaml config to show laravel error

Ok, thanks <3 That doesn't solve my problem, but let's just say that at least I know where to look

@driesvints I think the issue can be closed, sorry for the mess.

driesvints commented 6 months ago

@Akecel no worries