The site can not be reached issue
swagat123 opened this issue · 11 comments
Hi clone the git repository , then install django version is 1.11 as i have python 2.7 os Ubuntu (red hat linux).
so i comment the decouple , add some value to SECRET_KEY . then import path is for diajngo >2 , so i added the code as below
from django.contrib import admin
from django.conf.urls import url
from .views import home_view # handle_response
urlpatterns = [
url('admin/', admin.site.urls),
]
urlpatterns += [
url('', home_view, name='home'),
# path('chat/', handle_response, name='chat')
]
then run the python manage.py runserver i got the below message
Performing system checks...
System check identified no issues (0 silenced).
You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
December 05, 2018 - 19:55:24
Django version 1.11.17, using settings 'chatsite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
as i have update rasa nlu and rasa core version , i rebuild the model again.
after that i ran python bot.py
then open the link http::8000/ -- it is showing the site can not be reached , connection refused.
do i have to add any settings, configuration to do.
please advice.
Hello Alexmhack, thanks for the code. I'm using django 2.1.2 and python3.6, I replaced models, put the secret key, installed python-decouple
, django-cors-headers
modules with pip, also added two lines in the template index.html:
hideWhenNotConnected: false
- to be able to always see the bot window.
connectingText: "Waiting for server..."
- to see the bot's status
After doing all that and running python manager runserver
and python rasachat/bot.py
I cannot type a message inside of the bot's window, so cannot interact with the bot :( I see that it cannot connect to socket io server apparently... Any ideas how to fix it ? Thanks.
Been busy on a project, will soon respond to all the issues.
Hi clone the git repository , then install django version is 1.11 as i have python 2.7 os Ubuntu (red hat linux).
so i comment the decouple , add some value to SECRET_KEY . then import path is for diajngo >2 , so i added the code as below
from django.contrib import admin from django.conf.urls import url from .views import home_view # handle_response urlpatterns = [ url('admin/', admin.site.urls), ] urlpatterns += [ url('', home_view, name='home'), # path('chat/', handle_response, name='chat') ]
then run the python manage.py runserver i got the below message
Performing system checks... System check identified no issues (0 silenced). You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. December 05, 2018 - 19:55:24 Django version 1.11.17, using settings 'chatsite.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
as i have update rasa nlu and rasa core version , i rebuild the model again.
after that i ran python bot.pythen open the link http::8000/ -- it is showing the site can not be reached , connection refused.
do i have to add any settings, configuration to do.
please advice.
You need to make sure that the port which is 5500 in my code for socket connection in bot.py file and in templates/index.html is same, also the site can not be reached , connection refused. error's most probable cause is due to the defect in the server run by bot.py, server is not running on the port 5500, try to run the file again in another command prompt.
If this not works, then send me the actual error logs that are in the command prompt.
Hello Alexmhack, thanks for the code. I'm using django 2.1.2 and python3.6, I replaced models, put the secret key, installed
python-decouple
,django-cors-headers
modules with pip, also added two lines in the template index.html:
hideWhenNotConnected: false
- to be able to always see the bot window.
connectingText: "Waiting for server..."
- to see the bot's status
After doing all that and runningpython manager runserver
andpython rasachat/bot.py
I cannot type a message inside of the bot's window, so cannot interact with the bot :( I see that it cannot connect to socket io server apparently... Any ideas how to fix it ? Thanks.
The mrbot-ai/rasa-webchat script needs internet connection for loading html, make sure you are connected to internet.
Also have you tried running the bot before making any of the changes in my code, if it works without making changes then there is some error made by your changes that unable you to type a message inside of the bot's window,
Are there any errors shown in the command prompt, comment them here, I will try my best to solve the errors.
thanks for replying raymond,
without changes when just cloning your repo, I get this error for python bot.py
:
`(venv) user@user-SATELLITE-L50-B:~/django/Django-Rasa-Bot/rasachat$ python bot.py/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/pykwalify/core.py:99: UnsafeLoaderWarning:
The default 'Loader' for 'load(stream)' without further arguments can be unsafe.
Use 'load(stream, Loader=ruamel.yaml.Loader)' explicitly if that is OK.
Alternatively include the following in your code:
import warnings
warnings.simplefilter('ignore', ruamel.yaml.error.UnsafeLoaderWarning)
In most other cases you should consider using 'safe_load(stream)'
data = yaml.load(stream)
2019-01-02 09:51:28.458384: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Traceback (most recent call last):
File "bot.py", line 6, in
agent = Agent.load('models/dialogue', interpreter='models/current/nlu')
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/rasa_core/agent.py", line 263, in load
ensemble = PolicyEnsemble.load(path) if path else None
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/rasa_core/policies/ensemble.py", line 186, in load
policy = policy_cls.load(policy_path)
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/rasa_core/policies/keras_policy.py", line 240, in load
model = load_model(model_file)
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/tensorflow/python/keras/engine/saving.py", line 229, in load_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/tensorflow/python/keras/engine/saving.py", line 306, in model_from_config
return deserialize(config, custom_objects=custom_objects)
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/tensorflow/python/keras/layers/serialization.py", line 64, in deserialize
printable_module_name='layer')
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 173, in deserialize_keras_object
list(custom_objects.items())))
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/tensorflow/python/keras/engine/sequential.py", line 293, in from_config
layer = layer_module.deserialize(conf, custom_objects=custom_objects)
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/tensorflow/python/keras/layers/serialization.py", line 64, in deserialize
printable_module_name='layer')
File "/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 193, in deserialize_keras_object
function_name)
ValueError: Unknown layer:layers
`
considering that I'm using rasa-core==0.11.9 (cause it says the model is too old for newer version like 0.12.3), django==2.1.4, python==3.5
Try upgrading the rasa core to its latest version, I trained the model with the latest version and for the bot to work on some other version it needs to be trained again with that version, you can either upgrade the rasa core or simply run the commands for training the chatbot again.
Run the below commands
python -m rasa_core.train -d domain.yml -s stories.md -o models/dialogue
python -m rasa_nlu.train -c nlu_config.yml --data nlu.md -o models --fixed_model_name nlu --project current --verbose
Then again run the django server and bot.py file and see if there are any errors now.
ok, trained the model (looked ok), had to pip install sklearn_crfsuite
, got this after executing python bot.py
`(venv) user@user-SATELLITE-L50-B:~/django/Django-Rasa-Bot/rasachat$ python bot.py
/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/pykwalify/core.py:99: UnsafeLoaderWarning:
The default 'Loader' for 'load(stream)' without further arguments can be unsafe.
Use 'load(stream, Loader=ruamel.yaml.Loader)' explicitly if that is OK.
Alternatively include the following in your code:
import warnings
warnings.simplefilter('ignore', ruamel.yaml.error.UnsafeLoaderWarning)
In most other cases you should consider using 'safe_load(stream)'
data = yaml.load(stream)
2019-01-02 12:16:02.444857: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
/home/user/django/Django-Rasa-Bot/venv/lib/python3.5/site-packages/rasa_nlu/extractors/entity_synonyms.py:85: UserWarning: Failed to load synonyms file from 'models/current/nlu/entity_synonyms.json'
"".format(entity_synonyms_file))
127.0.0.1 - - [2019-01-02 12:16:08] "GET /socket.io/?EIO=3&transport=polling&t=MWEHnxN HTTP/1.1" 200 365 0.001006
127.0.0.1 - - [2019-01-02 12:16:08] "POST /socket.io/?EIO=3&transport=polling&t=MWEHnyD&sid=f4248e0bb0d64b578ce2a34ed7f9e24f HTTP/1.1" 200 195 0.000539
127.0.0.1 - - [2019-01-02 12:16:33] "POST /socket.io/?EIO=3&transport=polling&t=MWEHu2o&sid=f4248e0bb0d64b578ce2a34ed7f9e24f HTTP/1.1" 200 195 0.000577
127.0.0.1 - - [2019-01-02 12:16:33] "GET /socket.io/?EIO=3&transport=polling&t=MWEHnyE&sid=f4248e0bb0d64b578ce2a34ed7f9e24f HTTP/1.1" 200 211 24.998071
127.0.0.1 - - [2019-01-02 12:16:58] "POST /socket.io/?EIO=3&transport=polling&t=MWEH-AD&sid=f4248e0bb0d64b578ce2a34ed7f9e24f HTTP/1.1" 200 195 0.000262
127.0.0.1 - - [2019-01-02 12:16:58] "GET /socket.io/?EIO=3&transport=polling&t=MWEHu3b&sid=f4248e0bb0d64b578ce2a34ed7f9e24f HTTP/1.1" 200 211 25.000428
127.0.0.1 - - [2019-01-02 12:17:02] "GET /socket.io/?EIO=3&transport=polling&t=MWEH_3M HTTP/1.1" 200 365 0.000563
`
anyway on the web page I see only the h1 title, since webchat is not connected to server I guess it doesn't show it even
Everything looks okay, the socket server is accepting connections and one more thing even if the webchat is not connected to the server it will show up but won't reply to your messages. There definitely is something wrong with the webchat script that is in the html template. Check the webchat docs and try some variations in its script, try refreshing the browser window, make sure your computer is connected to internet.
Also you can check my repo Django-Rasa-Sockets which is also for rasa core chatbot connecting with django backend using sockets and without using the webchat chatbot widget.
@t3loki I have the same problem like you. Sockets are connected and when I refresh the page I see GET and POST request in terminal and white page like yours in the browser. Did you solve it?
@Alexmhack it worked with Django-Rasa-Sockets maybe has to do something from the javascript side like installing nodejs and bundle things. Not sure about this right now.
didn't solve the webchat but Django-Rasa-Sockets works :) thanks
Alexmhack. that's a nice starting point.
Installed npm inside python virtualenv from here
Also had to install this:
npm install base64-arraybuffer
npm install engine.io-parser
npm install socket.io-client
pip install django-cors-headers
pip install sklearn_crfsuite
webchat widget has been updated and so you need to use the latest script that is available on their github page which has option to hide the widget when not connected to any socket server. Try by running the socket server first and then loading the django server so that widget shows up on connection or you write your own widget from scratch taking webchat as a reference in that case your chatbot data will also not go through a third party.