Git Product home page Git Product logo

Comments (6)

andrewgodwin avatar andrewgodwin commented on May 22, 2024

It looks fine to me at first glance - and if Firefox connects it means websocket is getting through alright. What error do you get from the other browsers?

from daphne.

zeezdev avatar zeezdev commented on May 22, 2024

I forgot to say that a successful connection I get by means of little hack in my routing.py:

def ws_connect(message, pk):
    logger.info("WS: connected new user with pk={}".format(pk))
    try:
        user = User.objects.get(pk=pk)
        if not user.is_authenticated():
            logger.warn("WS: user pk={} is not authenticated".format(pk))
            return  # using /stream/ (devices) only for authenticated users
        Group(user.group_name).add(message.reply_channel)

        # FIXME: little hack, send a message for connection establishment
        group = Group(user.group_name)
        group.send({
                "text": json.dumps({
                        'payload': {
                            'action': 'connection',
                            'data': {}
                        }
                    }
                ),
        })
    except ObjectDoesNotExist:
        logger.warn("WS: user for pk={} not found".format(pk))
    except Exception as ex:
        logger.error(ex)

Without sending of the empty message the connection does not established and in Firefox too.
Without sending the message I get records in the log about that the client has been connected but immediately there are disconnection of the websocket client and I have messages in my browser:

WebSocket connection to 'wss://my.domain.net:8443/4/stream/' failed: WebSocket is closed before the connection is established.

and after a few attempt:

reconnecting-websocket.min.js:1 WebSocket connection to 'wss://my.domain.net:8443/4/stream/' failed: Error in connection establishment: net::ERR_TIMED_OUT

from daphne.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

Ah, it's because you're not accepting the connection like 1.0 now requires! See http://channels.readthedocs.io/en/latest/releases/1.0.0.html#connect-consumers

from daphne.

zeezdev avatar zeezdev commented on May 22, 2024

Thanks for your hint! I'll try it soon.

from daphne.

andrewgodwin avatar andrewgodwin commented on May 22, 2024

Closing due to lack of response.

from daphne.

fuzilogik avatar fuzilogik commented on May 22, 2024

Hi

I am experiencing a very similar issue to zeezdev. My setup is almost identical, besides me using Apache instead of nginx. I keep getting "WebSocket is closed before the connection is established." warnings followed by a "WebSocket opening handshake timed out" error after the web socket not being able to connect. Is there a suggested fix for this? I am running daphne with letsencrypt certificates in much the same was as described by zeezdev.

from daphne.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.