kakajansh / echo

Laravel Echo for your Flutter apps.
MIT License
108 stars 69 forks source link

Not working #9

Closed ghost closed 4 years ago

ghost commented 5 years ago

Hello,

When I try to connect to the server, nothing happens.

Here's what I tested:

  Echo echo = new Echo({
    'broadcaster': 'socket.io',
    'client': IO.io,
    'host': "http://192.168.0.16:6001",
    'autoConnect': true
  });

void initState () {
    super.initState();
    echo.channel('public-channel').listen('TestEvent', (e) =>print(e));
  }

On the laravel-echo development server, I don't see any connecting events (everything works with JS).

adamanderson86 commented 5 years ago

Check out this https://github.com/rikulo/socket.io-client-dart/issues/28 I was having any issue and this fixed it

ghost commented 5 years ago

@adamanderson86

Hello, This

Echo echo = new Echo({
    'broadcaster': 'socket.io',
    'client': IO.io('http://192.168.0.16:6001', <String, dynamic>{'transports': ['websocket']}),
    'host': "http://192.168.0.16:6001",
    'autoConnect': true
  });

Does not work.

=> Class 'Socket' has no instance method 'call'.

I want to use Echo library, not socket.io, which is just the client if I understood correctly.

bhargavsejpalindianic commented 5 years ago

Having same issue it shows connected but Listener not working

kakajansh commented 5 years ago

@dayfault @bhargavsejpalindianic Did you try creating Echo instance in initState as provided in example

void initState () {
  super.initState();

  Echo echo = new Echo({
    'broadcaster': 'socket.io',
    'client': IO.io,
    'host': 'http://192.168.0.16:6001'
  });

  echo.channel('public-channel').listen('TestEvent', (e) => print(e));
}
bhargavsejpalindianic commented 5 years ago

it just worked problem was in internal server thanks for quick response @kakajansh

ghost commented 5 years ago

@kakajansh Hello.

Yes I tried to creating instance in initState, not working. I can't see any event in Echo console, just


version 1.5.0

⚠ Starting server in DEV mode...

✔  Running at 0.0.0.0 on port 6001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...

Server ready!

Here is my laravel-echo-server.json :

{
    "authHost": "http://localhost",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {},
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "host": "0.0.0.0",
    "port": "6001",
    "protocol": "http",
    "socketio": {},
    "sslCertPath": "",
    "sslKeyPath": "",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": {
        "http": true,
        "redis": true
    },
    "apiOriginAllow": {
        "allowCors": false,
        "allowOrigin": "",
        "allowMethods": "",
        "allowHeaders": ""
    }
}

I tried with an Android Studio lib, it works. Same with JavaScript lib. But I need to use Flutter.

Edit1: I am using a VirtualBox machine on Manjaro Linux to host my Echo server. I don't think that's the problem, since as I said, I tried with other libs and it worked