Git Product home page Git Product logo

websocketappdemo's Introduction

GosWebSocketBundle Demo

This is a demo application based on a stripped down version of the Symfony website skeleton. To test this demo:

  • Clone this repository to your test server (git clone [email protected]:GeniusesOfSymfony/WebsocketAppDemo.git)
  • Enter the directory where you cloned this demo app (i.e. cd WebsocketAppDemo)
  • Optional: Check out the branch you wish to use:
    • Use the 1.x branch for GosWebSocketBundle 1.x
    • Use the 2.x branch for GosWebSocketBundle 2.x
    • Use the master branch for GosWebSocketBundle 3.x
  • Run composer install to install all dependencies
  • Start the websocket server with the php bin/console gos:websocket:server command
  • Visit the app's homepage in your browser
  • Check the browser's console log

websocketappdemo's People

Contributors

0mars avatar achilleash avatar dependabot[bot] avatar jjsaunier avatar mbabker avatar prophet777 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

websocketappdemo's Issues

Composer install error:

composer_error
I'm trying to run the demo on Docker (Windows) with php7.2 but I can't get past this issue. Maybe I'm missing something simple, I'd appreciate your input.

Variable "gos_web_socket_server_host" does not exist.

I just did the following:

  1. Clone the repository
  2. cd WebSocketAppDemo
  3. composer install
  4. symfony server:start, it's running on port 8000
  5. Open a new tab of my terminal
  6. php bin/console gos:websocket:server
  7. Open Safari, go to https://127.0.0.1:8000

I get the following error:

Capture d’écran 2020-11-18 à 15 37 06

It seems the variables required in the homepage template (line 12) are not set in Symfony. Did I do something wrong?

Disconnecting on subscribing/publishing

I set up a websockets server locally running via wss and I can connect to it successfully:

websocket.on("socket/connect", function(session){
        console.log('connected');
}

works as expected.

However, once I try

session.subscribe("chat", function(uri, payload){
    console.log("Received message", payload.msg);
 });

I am immediately disconnected. In Firefox the message is "Disconnected: Connection lost - scheduled 1th reconnect to occur in 5 second(s). With code 6"

From the server side the log display as follows:

17:36:15 DEBUG     [websocket] INSERT CLIENT 897 ["user" => "s:36:"anon-8148039825a8aeeef50fab594866255";"] []
17:36:15 INFO      [websocket] anon-8148039825a8aeeef50fab594866255 connected ["connection_id" => 897,"session_id" => "8148039825a8aeeef50fab594866255","storage_id" => 897] []
17:36:15 DEBUG     [websocket] GET CLIENT 897 [] []
17:36:15 INFO      [websocket] anon-8148039825a8aeeef50fab594866255 subscribe to chat [] []
17:36:20 DEBUG     [websocket] INSERT CLIENT 894 ["user" => "s:37:"anon-12065318285a8aeeea4b641205203743";"] []

I added the respective topic with a name "chat" and registered it as a service with the correct tag.

Is there something I am missing here? Could it be that this problem is related to usage via SSL?

RPC handler acme.rpc not exists, only [ ] are available

I have setup websocket in my project and follow Installation Instructions as you mention.
your demo is working nice but, when i tried to implement it on my project, I'm getting

rpc handler acme.rpc not exists, only [ ] are available
error.

I'm attaching code which i did.
config.yml
gos_web_socket: server: port: 8081 #The port the socket server will listen on host: 192.168.1.32 #The host ip to bind to router: resources: - '@SlideshowSocketBundle/Resources/config/pubsub/routing.yml'

pubsub_routing.yml
acme_rpc: channel: api/{method} handler: callback: 'acme.rpc' #related to the getName() or your RPC service requirements: method: pattern: "[a-z_]+"

AcmeRpc.php
`<?php
/**

  • Created by PhpStorm.
  • User: sotsys-161
  • Date: 2/7/16
  • Time: 12:26 PM
    */

namespace Slideshow\SocketBundle\RPC;

use Ratchet\ConnectionInterface;
use Gos\Bundle\WebSocketBundle\RPC\RpcInterface;
use Gos\Bundle\WebSocketBundle\Router\WampRequest;

class AcmeRpc implements RpcInterface
{
/**
* Adds the params together
*
* Note: $conn isnt used here, but contains the connection of the person making this request.
*
* @param ConnectionInterface $connection
* @param WampRequest $request
* @param array $params
* @return int
*/
public function sum(ConnectionInterface $connection, WampRequest $request, $params)
{
return array("result" => array_sum($params));
}

/**
 * Name of RPC, use for pubsub router (see step3)
 *
 * @return string
 */
public function getName()
{
    return 'acme.rpc';
}

}`

Suggestion for docs: please add docker-compose instructions

It's just a reminder for all people who try to run this project with docker-compose. I got errors

  • WebSocket connection to 'ws://127.0.0.1:1337/' failed: Connection closed before receiving a handshake response
  • Disconnected for Connection could not be established. with code 3

Solution: you should specify HOST=0.0.0.0 instead of 127.0.0.1.

Here is a sample docker-compose file:

version: '3.2'

services:
    web:
        build: app/docker/php
        ports:
            - 9000:9000
            - 1337:1337
        volumes:
            - ./:/var/www/html
        environment:
            SYMFONY_ENV: dev
        entrypoint: app/docker/php/docker-entrypoint.sh
    nginx:
        image: nginx:latest
        ports:
            - 80:80
        environment:
            - NGINX_PORT=80
            - WWW_DIR=/var/www/html/public
        volumes:
            - ./app/docker/nginx:/etc/nginx/conf.d
            - ./:/var/www/html
            - ./var/logs/nginx:/var/log/nginx
        command: /bin/bash -c "exec nginx -g 'daemon off;'"

networks:
    default:

I could provide files that I have in "app/docker" folder if needed. Or could create a Pull request if you'd like.

cboden/ratchet vs gos/ratchet

Hi,

I'm unable to run the demo because this error:

[Symfony\Component\Debug\Exception\ContextErrorException]
  Catchable Fatal Error: Argument 1 passed to Ratchet\Wamp\TopicManager::__construct() must implement interface Ratchet\Wamp\WampServerInterface, none given, called in /WebsocketAppDemo/app/cache/dev/appDevDebugProjectContainer.php on line 2060 and defined

This I guess is because both cboden/ratchet and gos/ratchet libs are required as deps. The code seems wrote for gos/ratchet but the problem is that the two libs have the same namespace with different constructors.

Can you fix it?

Demo not working

Fatal error: Class 'Symfony\Component\Debug\Debug' not found in /WebsocketAppDemo/web/app_dev.php on line 21

Tried to install manually symfony/debug, no luck

Not working in live server

Hello,

Your demo is nicely working on localhost.
But, When i move to live, it is not working. Getting the following error.

_An exception has been thrown during the compilation of a template ("Unable to find file "@GosWebSocketBundle/Resources/public/js/vendor/autobahn.min.js".") in "GosWebSocketBundle::client.html.twig".

Here is the screen shot of error page.
an exception has been thrown during the compilation of a template unable to find file goswebsocketbundle resources public js vendor autobahn min js in goswebsocketbundle client html twig 500 internal server error

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.