CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate using an letsencrypt-signed webserver | flutter

I have spent so many hours just to figure this out. I use wss(secure) for my django websocket. Ive realized that using firebase and firecamp is working perfectly, but in my flutter app websocket connect it does not work. arggg, spending many hours working this error (I initially dont know why the heck is this).

Adding this piece of code in the main.dart file fix my issue. :)

Using Token as authentication for websocket | django == 4.0.3 | channels == 3.0.4

Using Token as authentication for websocket


        django == 4.0.3
        channels == 3.0.4

Important notice: must declare first before, AuthMiddlewareStack.

import os
import django

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myapp.settings')


from channels.auth import AuthMiddlewareStack

1.Add in your django app.