Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Stuck in "Waiting for server..." #59

Closed
jeanpah opened this issue Jan 16, 2019 · 11 comments
Closed

Stuck in "Waiting for server..." #59

jeanpah opened this issue Jan 16, 2019 · 11 comments

Comments

@jeanpah
Copy link

jeanpah commented Jan 16, 2019

Hi, i need some help please

Im trying to use the plugin with socket.io in localhost but the chat plugin gets stuck at "Waiting for server..." phase.
This is the code fragment i'm using for the web server:

const server = require('http').createServer();
const io = require('socket.io')(server);
io.on('connection', function(socket){
  console.log('a user connected');
  //console.log(socket)
  io.emit('bot_uttered', {"text": "hola, soy jean pierre el servidor"})
  socket.on('user_uttered',function(message){
    console.log(message);
    return true;
  });
  return true;
});


server.listen(3000);

When the client connects the message from the server is sent but im unable to write from the client side.

im suspecting that it has something to do with
initPayload: "/get_started"
but i havent found anywhere what that options is suposed to do.

Thaks!

@colinhobbs
Copy link

colinhobbs commented Jan 16, 2019

i am seeing the same behavior..

Using webchat Versions 0.5.3, 0.5.2 or 0.5.0 in a <script> tag

I see client the connection to my Rasa Server and its sending a Session_request event, but it does not appear to be sending the initPayload. ( or at least rasa is not registering it. )
web console is free of errors.
dropping back to webchat version 0.4.2 everything works as expected..

script config

   WebChat.default.init({
   selector: "#webchat",
   initPayload: "utter_greet",
   interval: 1000, // 1000 ms between each message
   socketUrl: "http://test-server:5004",
   socketPath: "/socket.io/",
   title: "Web Chat",
   inputTextFieldHint: "Type a message...",
   connectingText: "Waiting for server...",
   fullScreenMode: false,
   profileAvatar: "http://test-server:8080/images/dhelmet.png",
   hideWhenNotConnected: false,
       params: {
         images: {
             dims: {
           width: 300,
          height: 200,
             }
       },
   storage: "local"
   }
   })
   WebChat.show()

rasa-core 0.12.4
rasa-core-sdk 0.12.1
rasa-nlu 0.13.8

Rasa Logs

2019-01-16 16:48:48 INFO     engineio  - a58e949e8fd34a8293791f08992524a9: Sending packet OPEN data {'sid': 'a58e949e8fd34a8293791f08992524a9', 'pingTimeout': 60000, 'upgrades': [], 'pingInterval': 25000}
2019-01-16 16:48:48 INFO     engineio  - a58e949e8fd34a8293791f08992524a9: Sending packet MESSAGE data 0
10.83.174.147 - - [2019-01-16 16:48:48] "GET /socket.io/?EIO=3&transport=polling&t=MXOsaeq HTTP/1.1" 200 366 0.001168
2019-01-16 16:48:48 INFO     engineio  - a58e949e8fd34a8293791f08992524a9: Received packet MESSAGE data 2["session_request",{}]
2019-01-16 16:48:48 INFO     socketio  - received event "session_request" from a58e949e8fd34a8293791f08992524a9 [/]
10.83.174.147 - - [2019-01-16 16:48:48] "POST /socket.io/?EIO=3&transport=polling&t=MXOsarn&sid=a58e949e8fd34a8293791f08992524a9 HTTP/1.1" 200 196 0.000820
2019-01-16 16:49:13 INFO     engineio  - a58e949e8fd34a8293791f08992524a9: Received packet PING data None
2019-01-16 16:49:13 INFO     engineio  - a58e949e8fd34a8293791f08992524a9: Sending packet PONG data None

Hope that helps...

@znat
Copy link
Contributor

znat commented Jan 17, 2019

Are you able to talk to the bot? Does it answer?

@jeanpah
Copy link
Author

jeanpah commented Jan 17, 2019

@znat No, the input is disabled. but the connection to the server is logged. Im using firefox, the version of the plugin is the latest, im using the script tag.

@colinhobbs Thanks!, this rolling back the js client to version 0.4.2 make it work as expected.

@znat
Copy link
Contributor

znat commented Jan 17, 2019

Did you set session_persistence: true in the SocketIOInput section of the credentials.yaml file?

@jeanpah
Copy link
Author

jeanpah commented Jan 17, 2019

@znat sorry i'm using only socket.io for the backend, im not using rasa at the moment. but usign version 0.4.2 made the plugin work with a simple echo bot:

const server = require('http').createServer();
const io = require('socket.io')(server);
io.on('connection', function(socket){
  console.log('a user connected');
  //console.log(socket)
  io.emit('bot_uttered', {"text": "hola, soy jean pierre el servidor"})
  socket.on('user_uttered',function(message){
    io.emit('bot_uttered', {"text": message.message})
    return true;
  });
  return true;
});


server.listen(3000);

@colinhobbs
Copy link

with rasa.. I do have the session persistence set ..
Rasa config

socketio:
  user_message_evt: user_uttered
  bot_message_evt: bot_uttered
  session_persistence: true

I do see the client request a session.. just not seeing rasa respond at all to that request...

I used @jeanpah config on nodejs and could see the same result.. in looking at the logs i see the client connect. I guess i'm not sure what the client is looking for to confirm it has a connection to the server because you can see the client send the heardbeat ping and pong..

Rasa logs

2019-01-17 10:01:38 INFO     engineio  - 4c907a17d8fb4bbcbbe7bdfc15bd4a58: Sending packet OPEN data {'sid': '4c907a17d8fb4bbcbbe7bdfc15bd4a58', 'pingInterval': 25000, 'pingTimeout': 60000, 'upgrades': []}
2019-01-17 10:01:38 INFO     engineio  - 4c907a17d8fb4bbcbbe7bdfc15bd4a58: Sending packet MESSAGE data 0
10.21.144.93 - - [2019-01-17 10:01:38] "GET /socket.io/?EIO=3&transport=polling&t=MXSY-Lb HTTP/1.1" 200 366 0.001052
2019-01-17 10:01:39 INFO     engineio  - 4c907a17d8fb4bbcbbe7bdfc15bd4a58: Received packet MESSAGE data 2["session_request",{}]
2019-01-17 10:01:39 INFO     socketio  - received event "session_request" from 4c907a17d8fb4bbcbbe7bdfc15bd4a58 [/]
10.21.144.93 - - [2019-01-17 10:01:39] "POST /socket.io/?EIO=3&transport=polling&t=MXSY-OP&sid=4c907a17d8fb4bbcbbe7bdfc15bd4a58 HTTP/1.1" 200 196 0.000743
2019-01-17 10:02:04 INFO     engineio  - 4c907a17d8fb4bbcbbe7bdfc15bd4a58: Received packet PING data None
2019-01-17 10:02:04 INFO     engineio  - 4c907a17d8fb4bbcbbe7bdfc15bd4a58: Sending packet PONG data None
10.21.144.93 - - [2019-01-17 10:02:04] "POST /socket.io/?EIO=3&transport=polling&t=MXSZ4V1&sid=4c907a17d8fb4bbcbbe7bdfc15bd4a58 HTTP/1.1" 200 196 0.000714
10.21.144.93 - - [2019-01-17 10:02:04] "GET /socket.io/?EIO=3&transport=polling&t=MXSY-OQ&sid=4c907a17d8fb4bbcbbe7bdfc15bd4a58 HTTP/1.1" 200 212 24.952678

Hope that helps..

@hrqiang
Copy link

hrqiang commented Jan 17, 2019

I've resolved this issue recently. This will not be an issue once rasa_core release a new version. 0.12.4+.
For now, the work around is you install a github latest version rasa-core or replace your channels/socketio.py with github latest one.

@jeanpah
Copy link
Author

jeanpah commented Jan 18, 2019

@hrqiang Is there any solution for socket.io?

@dliuproduction
Copy link
Contributor

check issue #28

@jeanpah
Copy link
Author

jeanpah commented Jan 28, 2019

Hi everyone,

I managed to make the plugin work in version 0.5.3 with socket.io. it was fixed by adding two more events to the socket script "session_request, session_confirm":

const server = require('http').createServer();
const io = require('socket.io')(server);
const request = require('request');


io.on('connection', function(socket){
  console.log('a user connected');
  //console.log(socket)

  socket.on('session_request',function(id){
    return id.session_id
  })

  io.emit("session_confirm","hola")
  io.emit('bot_uttered', {"text": "hola, soy jean pierre el servidor"})

  socket.on('user_uttered',function(message){
    bot_data = {
      "object":"page",
      "entry":[
        {
          "messaging":[
            {
              "sender":{"id":"2149648825097538"},
              "recipient":{"id":"654472771621094"},
              "message": {"text":message.message}
            }
          ]
        }
      ]
    }


    var options = {
      uri: 'http://127.0.0.1:8080/messengerBotWebhook',
      method: 'POST',
      json: bot_data
    };
    request(options, (err, res, body) => {
      if (err) { return console.log(err); }
      //console.log(body.url);
      try{
        result = JSON.parse(body);
        console.log(result)
      }catch(e){
        console.log(e)
      }
    });
    io.emit('bot_uttered', {"text": "simon dice "+message.message})
    return true;
  });
  return true;
});


server.listen(3000);

@znat
Copy link
Contributor

znat commented Jan 29, 2019

Right, of course! Thanks @jeanpah .
Would you consider adding them in the readme in a PR?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants