Got an issue trying to connect from an async view in Django 3.1 to a sync view served by the same asgi server. Doing this in normal wsgi development server works, but not in an asgi server. Which seems kind of weird. Probably I misunderstood on how asgi works :). Here's a link on how to reproduce this:
Here are just the views causing the problem. Maybe someone is able to tell immediately what I'm doing wrong by just looking at those:
import httpx
from django.http import JsonResponse
def sync_api_view(request):
payload = {"foo": "bar"}
return JsonResponse(payload)
def sync_aggregation_view(request):
responses = []
r = httpx.get("http://127.0.0.1:8000/sync_api_view/")
responses.append(r.json())
result = {"responses": responses}
return JsonResponse(result)
The "sync_aggregation_view" is the one that works in wsgi but not via asgi.