How to locate websocketbridge.js in Django using channels websocket?

前端 未结 2 1107
广开言路
广开言路 2021-01-21 14:23

I am trying to implement websockets using channels in Django project. I am getting 404 for webscoketbridge.js Below is html template. {% load staticfiles %}

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-21 14:58

    As the way @tobyspark said, javascript wrapper has been completely removed in the django-channels 2. You can read more on how the js websocket wrapper was working in channels 1 here.

    the simplest workaround to clear that error in your browser create a file called websocketbridge.js in the path shown in the error, "static/channels/js/", or you can specify any other path in your HTML src attribute matching the location of the static files and then add the code from here.

    But you have to find a better implementation. You can use ReconnectingWebSocket. In the channels 2 release documentation, it is stated there might be other third-party packages for the binding but I don't know any other.

提交回复
热议问题