botfront / rasa-webchat

A feature-rich chat widget for Rasa and Botfront
https://botfront.io/rasa
Apache License 2.0
964 stars 496 forks source link

Rasa-webchat widget appears to connect to rasa server, but keeps saying "Waiting for server..." #28

Closed mmenti closed 5 years ago

mmenti commented 5 years ago

I’m running the Rasa stack starter pack example with the Rasa webchat widget, embedded as JS script, using the Rasa server socketio setup.

It appears to connect successfully (i.e. when running the rasa stack server, I see the log messages that suggest POST and GET request to e.g. /socket.io/?EIO=3&transport=polling&t=MThFYM_&sid=cfc8653cd08d4ba98127487495d5ad6a are successful and return a 200 code, but the web widget on the page continues to say “Waiting for server…” and the user input field stays disabled. There are also no XHR error messages from the web inspector, suggesting the connection to the Rasa stack server works (I can see these errors as soon as I stop the rasa server).

I feel I'm missing something obvious here, but I’m kind of lost trying to figure out what makes the webchat widget think it is not connected to the server - any pointers or suggestions would be very welcome, thanks!

znat commented 5 years ago

@mmenti do you see the session id log in the console? Can you paste the snippet with the parameters?

mmenti commented 5 years ago

@znat yes, in the console I can see "connect:5fddce85aaaf403290476e42896c10f5", and the Rasa stack logs show for this session id:

2018-12-03 13:56:44 INFO     engineio  - 5fddce85aaaf403290476e42896c10f5: Received packet PING data None
2018-12-03 13:56:44 INFO     engineio  - 5fddce85aaaf403290476e42896c10f5: Sending packet PONG data None
86.16.184.99 - - [2018-12-03 13:56:44] "POST /socket.io/?EIO=3&transport=polling&t=MTqMrkA&sid=5fddce85aaaf403290476e42896c10f5 HTTP/1.1" 200 190 0.000647
86.16.184.99 - - [2018-12-03 13:56:44] "GET /socket.io/?EIO=3&transport=polling&t=MTqMlUy&sid=5fddce85aaaf403290476e42896c10f5 HTTP/1.1" 200 206 25.517103

Is that the info you wanted?

znat commented 5 years ago

Can you share the js snippet you are using? The one in your script tag?

mmenti commented 5 years ago

Sure (I tried both webchat-latest and 0.5.0 with no difference):

<script src="https://storage.googleapis.com/mrbot-cdn/webchat-latest.js"></script>
<script>
  WebChat.default.init({
    selector: "#webchat",
    initPayload: "/story_greet",
    interval: 1000, // 1000 ms between each message
    customData: {"userId": "123"}, // arbitrary custom data. Stay minimal as this will be added to the socket
    socketUrl: "http://3.8.51.73:5002",
    socketPath: "/socket.io/",
    title: "Title",
    subtitle: "Subtitle",
    inputTextFieldHint: "Type a message...",
    connectingText: "Waiting for server...",
    fullScreenMode: false,
    profileAvatar: "",
    params: {
      images: {
        dims: {
          width: 300,
          height: 200,
        }
      },
      storage: "session"
    }
  });
  WebChat.show();
</script>
dliuproduction commented 5 years ago

Hi @mmenti,

After the connect:{sid} message, do you see something in console in the forms of:

session_confirm:{socker_id}
session_id:{session_id}

We implemented a session persistence feature which requires some server code to generate a session_id and perform a handshake.

The server changes are up in the latest release today at: rasa_core#0.12.3

Try it and see if it works. There should be no extra setup required.

mmenti commented 5 years ago

Thanks @dliuproduction - I just upgraded my rasa_core install and tried again, but the only thing I see in the Console is the "connect:{sid}" line, I don't see the 2 lines you mention at all. The only other thing I can see (if I choose to show XMLHTTPRequests) is the XHR GET and POST requests..

dliuproduction commented 5 years ago

Sorry, looks like the changes are not included yet in the latest release of rasa_core. It is already in the master branch though. Can you try to install rasa_core with:

pip install git+git://github.com/rasahq/rasa_core.git

The specific file is this socketio.py. If your local rasa_core has the session_request function then it is the right version.

mmenti commented 5 years ago

Sorry for the late reply - this ended up being quite a painful process, because the latest rasa core version doesn't support python 2.7 anymore, so I had to install python 3 - the problem being that on AWS Amazon Linux there is only 3.7 (which Tensorflow doesn't work with), so I ended up having to build 3.6 from source.

But eventually, after rebuilding the models etc using python 3, it now all seems to work - thanks so much for all the help @dliuproduction and @znat

mikakenku commented 5 years ago

Hello,

I face the same issue with the bot saying "Waiting for server..." I tried to install latest version of rasa core with the command line proposed by @dliuproduction : pip install git+git://github.com/rasahq/rasa_core.git

It doesn't solve the problem.

I'm not sure the good version of rasacore is installed. Here is the result :

# rasa --version
Rasa 0.15.0a1

I also tried to update rasa core with :

pip install --upgrade rasa_core

the result of rasa --version is the same Rasa 0.15.0a1

I don't know where to look now to investigate and solve the problem.

Can you help me please ?

Thanks a lot. Michael