问题
I'm running Rasa chatbot in container and apache2 in normal environment. When I open web page where chatbot is running there is no chatbot widget. When I run same configuration in my Virtual box environment, with Ubuntu 18.04 desktop, it works.
it only shows this, no error messages
// you can add a version tag if you need, e.g for version 0.11.5 https://cdn.jsdelivr.net/npm/rasa-webchat@0.11.5/lib/index.min.js
Some information below:
paulii@vetbot:~/rasaProd/rasaAsPa$ sudo netstat -plnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 839/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1073/sshd
tcp 0 0 127.0.0.1:29130 0.0.0.0:* LISTEN 1423/mdsd
tcp6 0 0 :::22 :::* LISTEN 1073/sshd
tcp6 0 0 :::444 :::* LISTEN 17464/apache2
tcp6 0 0 :::5005 :::* LISTEN 72983/docker-proxy
index.html
paulii@vetbot:~/rasaProd/rasaAsPa$ cat index.html
<head>
</head>
<body>
<div id="webchat"></div>
<script src="https://cdn.jsdelivr.net/npm/rasa-webchat/lib/index.min.js"></script>
// you can add a version tag if you need, e.g for version 0.11.5 https://cdn.jsdelivr.net/npm/rasa-webchat@0.11.5/lib/index.min.js
<script>
WebChat.default.init({
selector: "#webchat",
initPayload: "/aloitus",
customData: {"language": "en"}, // arbitrary custom data. Stay minimal as this will be added to the socket
socketUrl: "http://localhost:5005",
socketPath: "/socket.io/",
title: "Demo bot",
subtitle: "Subtitle",
params: {"storage": "session"} // can be set to "local" or "session". details in storage section.
})
</script>
</body>
</html>
sites-availale conf
paulii@vetbot:/etc/apache2/sites-available$ cat 000-default.conf
<VirtualHost *:444>
ServerAdmin webmaster@localhost
ServerName aspabotti1.omnia.fi
ServerAlias www.aspabotti1.omnia.fi
# DocumentRoot /home/linttu/rasaProd/rasaAsPa
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Rasa docker running
paulii@vetbot:/etc/apache2/sites-available$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
133db8a49155 rasa/rasa:1.10.11-full "rasa run -m models …" 2 minutes ago Up 2 minutes 0.0.0.0:5005->5005/tcp rasa2
Ubuntu environment
paulii@vetbot:/etc/apache2/sites-available$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.5 LTS
Release: 18.04
Codename: bionic
Docker version
paulii@vetbot:/etc/apache2/sites-available$ docker -v
Docker version 19.03.13, build 4484c46d9d
Apache2 version
paulii@vetbot:/etc/apache2/sites-available$ apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built: 2020-08-12T21:33:25
New testing 23.9.2020
I tested with javascript code below and that works. So why starting javascript started remotely doesn't work?
This doesn't work
<script src="https://cdn.jsdelivr.net/npm/rasa-webchat/lib/index.min.js"></script>
This works
<html>
<head>
<script language="JavaScript">
<!-- hide this script from old browsers
function temp(form)
{
var f = parseFloat(form.DegF.value, 10);
var c = 0;
c = (f - 32.0) * 5.0 / 9.0;
form.DegC.value = c;
}
// done hiding from old browsers -->
</script>
</head>
<body>
<FORM>
<h2>Fahrenheit to Celsius Converter</h2>
Enter a temperature in degrees F:
<INPUT NAME="DegF" VALUE="0" MAXLENGTH="15" SIZE=15>
<p>
Click this button to calculate the temperature
in degrees C:
<INPUT NAME="calc" VALUE="Calculate" TYPE=BUTTON
onClick=temp(this.form)>
<p>
Temperature in degrees C is:
<INPUT NAME="DegC" READONLY SIZE=15>
</FORM>
</body>
</html>
来源:https://stackoverflow.com/questions/63960043/botfront-webchat-widget-not-showing-at-azure-environment