Lms <-> discovery communication

Hello, we have a question regarding local development, not using real domains when setting up tutor.

We are trying to update the programs cache (tutor local run lms ./manage.py lms cache_programs), but it seems that lms can’t communicate with discovery service, we configure the site configuration (which is required to run the cache_program command) with the following value:

but we get:

ConnectionError: HTTPConnectionPool(host='discovery.localhost', port=80): Max retries exceeded with url: /api/v1/programs/?exclude_utm=1&status=active&status=retired&uuids_only=1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f23b5f46b50>: Failed to establish a new connection: [Errno 111] Connection refused',))

When we run quickstart we didn’t specify any domains for lms and studio, when we configure discovery service we set a random name to the DISCOVERY_HOST value.

I think that this issue can be reproduced by doing a fresh tutor installation, activating discovery and running the cache_programs command (which allows lms to “see” the programs).

Hi @cacciaresi! Welcome to my world :slight_smile: It’s difficult to define hostname settings that work both for development, production, server-side and client-side calls.

What happens here is that the LMS is trying to reach the discovery service at http://discovery.localhost. But remember that the LMS is running inside a docker container that is separate from the discovery container. So, from the point of view of the LMS, http://discovery.localhost points to the LMS.

To solve this issue, you should use COURSE_CATALOG_API_URL = "http://discovery:8000", as this is the url that the discovery service runs at, from the point of view of the LMS. If this works, we should probably define the COURSE_CATALOG_API_URL setting as part of the discovery plugin definition.

EDIT: this setting will be added to tutor v3.8.0.

Thanks for you answer, and yes indeed is hard ;), for example we tried to set the same host (localhost) for the domain but that will cause duplicated entries in some queries. It would be great if possible to have a guide on how to setup correctly the domains covering the three contexts (development, production, server-side and client-side calls).

Regarding this:

Where can we see where this is defined? So, where is defined that LMS will see discovery as “discovery”?

Again, thanks a lot!

With the recent introduction of a dedicated development docker image, I think it will make more sense to create dedicated development settings. I think this will improve the situation.

This is a “trick” made possible by docker-compose (and kubernetes services). By definition, the “discovery” container is reachable at the “discovery” domain name. See the docker-compose docs.

Great to know :wink: