0

I've a multisite installation of Drupal 8, the "main" website expose some REST webservices, locally i've some troubles on testing them, because there's no way for the various sites to see each other, when i try to do something like that

try {
  $response = $this->httpClient->get($this->baseUri . '/myendpoint', [
    'headers' => [
      'Accept' => 'application/json',
      'Content-type' => 'application/hal+json',
    ],
    'query' => [
      '_format' => 'json',
      'myparameters'  => 'value'
    ],
  ]);
  $results = $this->serializer->decode($response->getBody(), 'json');
}
catch (RequestException $e) {
  $this->logger->warning($e->getMessage());
}
return $results;

I always receive a timeout and there's no way i can make it work, i've my main website with the usual url project.ddev.site (and $this->baseUri is https://myproject.ddev.site ) and all the other websites are in the form subsite.ddev.local If i ssh in the project and run ping myproject.ddev.site i see 172.19.0.6 I don't understand why they cannot see each other...

Francesco
  • 55
  • 7
  • Please experiment with curl inside the container to see if you can nail this down. `curl https://subsite1.ddev.site`, etc. When you use a FQDN like that, it routes through the ddev-router, where SSL termination is done. – rfay May 29 '20 at 14:31
  • when i'm in (with ddev ssh) both curl https://mysite.ddev.site and curl https://subsite1.ddev.local respond, (the subsite with a symfony error, but that's not important i think, it respond and that's the important thing). One thing that maybe wasn't clear before is that in my case the services are defined on the main site, so the httpclient always call the main/default site – Francesco May 29 '20 at 14:54
  • If you can curl the main site from inside the container... then your app should also be able to access it. Sounds like something's wrong with the configuration? There's no difference between curl accessing the main site from inside the container and your app accessing the main site from inside the container. – rfay May 30 '20 at 22:12
  • Actually maybe i just found the problem... with xdebug active it behave like that, if i stop xdebug everything seems working... now i've configured it to work on only one domain and it seems ok, i think that maybe during the request it "gets stuck somewhere" not showing this thing in phpstorm... I've not thought to disable it before... – Francesco Jun 01 '20 at 12:37

1 Answers1

1

Just for other people who can have a similar problem: my issue was with xdebug i have it with the autoconnect, so when the request from the subsite to the main site was made, it get stuck somewhere (phpstorm didn't stop anywhere by the way) so it made the request time out.

By disabling, or configuring only for the subdomain, and avoiding it to accept the external connenction from unconfigured servers (in phpstorm) it started working, still have to do some work as i need to debug "both sides" of the request, but in this way i can work with that...

I've not thought before to try disabling xdebug because actually it didn't came into my mind...

Francesco
  • 55
  • 7
  • I definitely recommend working in general with xdebug disabled for performance reasons. `ddev xdebug off` is the default, and then just `ddev xdebug on` when you need it. – rfay Jun 02 '20 at 13:04
  • 1
    Yeah, you're right, i needed exactly to debug that call so it was active all the time in this case and i didn't think to disable it... Thanks for your time! – Francesco Jun 03 '20 at 15:40