GeniusesOfSymfony / WebSocketBundle

:part_alternation_mark: Websocket server for Symfony applications (powered by Ratchet), includes a Autobahn.JS based JavaScript client
MIT License
609 stars 140 forks source link

Uncaught ReferenceError: GosSocket is not defined #467

Open AbrahamCovelo opened 2 years ago

AbrahamCovelo commented 2 years ago

Following javascript client instructions here: https://github.com/GeniusesOfSymfony/WebSocketBundle/blob/3.x/docs/javascript-client.md

I got this error on my firefox Uncaught ReferenceError: GosSocket is not defined

This the final html I have (simplified at maximum) is this:

<!DOCTYPE html>

Welcome!
faiyazalam commented 1 year ago

@mbabker I am also facing the same issue. I am using this plugin first time and got stuck due to this issue. cc: @AbrahamCovelo

This is what I have in my layout.html.twig file:

    <script src="{{ asset('bundles/goswebsocket/js/vendor/autobahn.min.js') }}"></script>
    <script src="{{ asset('bundles/goswebsocket/js/websocket.min.js') }}"></script>
    <script>
     console.log(GosSocket); //Uncaught ReferenceError: GosSocket is not defined
    </script>

Both js files are loaded successfully.

benrcole commented 1 year ago

Change GosSocket to WS and it will work. Using WS is deprecated but it still functions, the documentation must be out of date with the most recent commit.

<script> var websocket = WS.connect('ws://127.0.0.1:8080'); </script>