I'm using Django-eventstream over Django channels to send an event to my client app (react using eventstream),
on my local machine the events are sent correctly to the client.
but when I upload the app to my Linux server the webhook just getting open and 'keep-alive' but the events won't get to the client at all.
I use daphne to deploy my Asgi app and use Nginx as my getaway.
when I use "python manage.py runserver" (on the Linux server) the client is getting all the messages.
because of that my clients do get the messages when I use runserver command I assume that my Nginx configuration is right (correct me if I'm wrong) and the problem is in Daphne somehow.
I don't see the events trying to be sent in the daphne logs at all.
does anyone have a clue why this is happening?
Thanks!
the command I used to run Daphne:
daphne --verbosity 3 -p 8001 my_project.asgi:application
here is my Daphne log:
[06/12/2019 14:52:34] INFO [daphne.cli:287] Starting server at tcp:port=8001:interface=127.0.0.1
2019-12-06 14:52:34,376 INFO Starting server at tcp:port=8001:interface=127.0.0.1
[06/12/2019 14:52:34] INFO [daphne.server:311] HTTP/2 support enabled
2019-12-06 14:52:34,377 INFO HTTP/2 support enabled
[06/12/2019 14:52:34] INFO [daphne.server:311] Configuring endpoint tcp:port=8001:interface=127.0.0.1
2019-12-06 14:52:34,377 INFO Configuring endpoint tcp:port=8001:interface=127.0.0.1
[06/12/2019 14:52:34] INFO [daphne.server:131] HTTPFactory starting on 8001
2019-12-06 14:52:34,378 INFO HTTPFactory starting on 8001
[06/12/2019 14:52:34] INFO [daphne.server:131] Starting factory <daphne.http_protocol.HTTPFactory object at 0x7fb1fd600cf8>
2019-12-06 14:52:34,378 INFO Starting factory <daphne.http_protocol.HTTPFactory object at 0x7fb1fd600cf8>
[06/12/2019 14:52:34] INFO [daphne.server:654] Listening on TCP address 127.0.0.1:8001
2019-12-06 14:52:34,379 INFO Listening on TCP address 127.0.0.1:8001
[06/12/2019 14:52:38] DEBUG [daphne.http_protocol:160] HTTP b'GET' request for ['127.0.0.1', 49034]
2019-12-06 14:52:38,215 DEBUG HTTP b'GET' request for ['127.0.0.1', 49034]
[06/12/2019 14:52:38] DEBUG [daphne.http_protocol:246] HTTP 200 response started for ['127.0.0.1', 49034]
Related
I am using Django 3.2.3, Apache and Daphne. Daphne is very slow.
I use Apache like a proxy to send the request to Daphne :
<VirtualHost *:443>
AllowEncodedSlashes On
ServerName mysite.com
ServerAdmin admin#gmail.com
ProxyPass "/" "http://127.0.0.1:8001/"
ProxyPassReverse "/" "http://127.0.0.1:8001/"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET" env=CORS
Header set Access-Control-Allow-Credentials "false" env=CORS
SSLCertificateFile /etc/letsencrypt/live/****/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/***/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
I launch Daphne with the command :
daphne -p 8001 asgi:application
When I access to my website, the log of Daphne are :
2021-06-04 21:17:17,821 INFO Adding job tentatively -- it will be properly scheduled when the scheduler starts
2021-06-04 21:17:17,865 INFO Added job "my_job" to job store "default"
2021-06-04 21:17:17,866 INFO Scheduler started
2021-06-04 21:17:17,909 INFO Starting server at tcp:port=8001:interface=127.0.0.1
2021-06-04 21:17:17,912 INFO HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2021-06-04 21:17:17,913 INFO Configuring endpoint tcp:port=8001:interface=127.0.0.1
2021-06-04 21:17:17,919 INFO Listening on TCP address 127.0.0.1:8001
127.0.0.1:34650 - - [04/Jun/2021:21:18:07] "GET /fr/" 200 234920209
127.0.0.1:34698 - - [04/Jun/2021:21:18:56] "GET /fr/jsi18n/" 304 -
It's working, I can display the webpage but it's very very slow, 30sec +
I have no idea of what to search, where to search ...
edit ---
Maybe the problem comes from the Apache proxy but I use 127.0.0.1, I do not see why it could be slow. ping 127.0.0.1 is fast.
edit 2 ---
Using dig and nslookup on 127.0.0.1 / localhost / SERVER ADDRESS is fast.
Can you help me maybe with some ideas ? or the solution :)
Thank you
Finally I have found.
The problem was not from apche but from my django code. I do not know exactly because I have a made a lot of tests but I think this is because the redis server was not launch.
Thank you
I am trying to run a django-channels project locally using https (the app has a facebook login that requires https).
I have followed the instructions for generating a key and certificate using mkcert ( https://github.com/FiloSottile/mkcert ) and have attempted to use the key and certificate by running daphne -e ssl:443:privateKey=localhost+1-key.pem:certKey=localhost+1.pem django_project.asgi:application -p 8000 -b 0.0.0.0
The server seems to be starting OK however when I try to visit https://0.0.0.0:8000 nothing happens and eventually I get a 'took too long to respond' message.
No new output is added to the standard daphne output that appears when I start up the server:
2019-07-16 19:23:27,818 INFO HTTP/2 support enabled
2019-07-16 19:23:27,818 INFO Configuring endpoint ssl:8443:privateKey=../sec/localhost+1-key.pem:certKey=../sec/localhost+1.pem
2019-07-16 19:23:27,823 INFO Listening on TCP address 0.0.0.0:8443
2019-07-16 19:23:27,823 INFO Configuring endpoint tcp:port=8000:interface=0.0.0.0
2019-07-16 19:23:27,824 INFO Listening on TCP address 0.0.0.0:8000
Can anyone help with this?
You should map the 8000 host port to port 443 of the container while runnig the server.
docker run ... -p 8000:443 ...
Turns out that setting up the Twisted ssl stuff overrides the port that you're setting up in daphne, so in the example above, the site would be shown on port 443
I am using an ubuntu/xenial64 vagrant box and following the instructions indicated here to set up a readthedocs server.
I am also hard coding a static private net IP in Vagrantfile:
config.vm.network "private_network", ip: "192.168.33.10"
However, after starting the Django server:
(rtd) vagrant#ubuntu-xenial:~/rtd/checkouts/readthedocs.org$ python manage.py runserver
[14/Mar/2018 05:22:40] root:120[1581]: INFO Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[14/Mar/2018 05:22:40] root:120[1581]: INFO Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
[14/Mar/2018 05:22:41] root:120[1585]: INFO Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[14/Mar/2018 05:22:41] root:120[1585]: INFO Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
Performing system checks...
System check identified some issues:
WARNINGS:
?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DEBUG.
?: (guardian.W001) Guardian authentication backend is not hooked. You can add this in settings as eg: `AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend', 'guardian.backends.ObjectPermissionBackend')`.
System check identified 2 issues (1 silenced).
March 14, 2018 - 05:22:42
Django version 1.9.12, using settings 'readthedocs.settings.dev'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
I am unable to access http://192.168.33.10:8000/
Within the vagrant machine:
vagrant#ubuntu-xenial:~$ netstat -ta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:8000 *:* LISTEN
tcp 0 0 localhost:6379 *:* LISTEN
Using
$ vagrant --version
Vagrant 2.0.2
and Virtualbox 5.2.8 r121009 (Qt5.6.1) on Ubuntu 16.04.03 host.
Everything is detailed at the end of the document
For builds to properly kick off as expected, it is necessary the port
you’re serving on (i.e. runserver 0.0.0.0:8080) match the port defined
in PRODUCTION_DOMAIN. You can utilize local_settings.py to modify
this. (By default, it’s localhost:8000)
You can do one of the two:
start the server with python manage.py runserver 0.0.0.0:8080
update local_settings.py and change localhost:8000 with 0.0.0.0:8080
You can also replace 0.0.0.0 with the IP you've configured for the VM
I have installed CouchDB in my AWS server. When I run the command
curl localhost:5984
then I got a response like:
{"couchdb":"Welcome","uuid":"b7a38141c61a37390945a99fd88f0015","version":"1.6.0","vendor":{"version":"15.10","name":"Ubuntu"}}
But when I run this command:
curl ip_address:5984
then it gives:
curl: (7) Failed to connect to Ip-address port 5984: Connection refused
Your CouchDB is not listening on all interfaces. Edit your couch.ini file and modify the line to:
bind_address = 0.0.0.0
and restart couch service. If it still doesn't work, post the output of netstat -plan | grep 5984.
Clearly explained here: CouchDB HTTP Server
bind_address : Defines the IP address by which CouchDB will be accessible:
[httpd]
bind_address = 127.0.0.1
To let CouchDB listen any available IP address, just set up 0.0.0.0 value:
[httpd]
bind_address = 0.0.0.0
I am using spark 0.90 stand alone mode.
When I tried with a streaming application in stand alone mode, I am getting a connection refused exception.
I added hostname in /etc/hosts also tried with IP alone. In both cases worker got registered with master without any issues.
Is there a way to solve this issue?
14/02/28 07:15:01 INFO Master: akka.tcp://driverClient#127.0.0.1:55891 got disassociated, removing it.
14/02/28 07:15:04 INFO Master: Registering app Twitter Streaming
14/02/28 07:15:04 INFO Master: Registered app Twitter Streaming with ID app-20140228071504-0000
14/02/28 07:34:42 INFO Master: akka.tcp://spark#127.0.0.1:33688 got disassociated, removing it.
14/02/28 07:34:42 INFO LocalActorRef: Message [akka.remote.transport.ActorTransportAdapter$DisassociateUnderlying] from Actor[akka://sparkMaster/deadLetters] to Actor[akka://sparkMaster/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FsparkMaster%4010.165.35.96%3A38903-6#-1146558090] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
14/02/28 07:34:42 ERROR EndpointWriter: AssociationError [akka.tcp://sparkMaster#10.165.35.96:8910] -> [akka.tcp://spark#127.0.0.1:33688]: Error [Association failed with [akka.tcp://spark#127.0.0.1:33688]] [
akka.remote.EndpointAssociationException: Association failed with [akka.tcp://spark#127.0.0.1:33688]
Caused by: akka.remote.transport.netty.NettyTransport$$anonfun$associate$1$$anon$2: Connection refused: /127.0.0.1:33688
I had a similar issue when running in Spark in cluster mode. My problem was that the server was started with the hostname 'fluentd:7077' and not the FQDN. I edited the
/sbin/start-master.sh
to reflect how my remote nodes connect with the -ip flag.
/usr/lib/jvm/jdk1.7.0_51/bin/java -cp :/home/vagrant/spark-0.9.0-incubating-bin- hadoop2/conf:/home/vagrant/spark-0.9.0-incuba
ting-bin-hadoop2/assembly/target/scala-2.10/spark-assembly_2.10-0.9.0-incubating-hadoop2.2.0.jar -Dspark.akka.logLifecycleEvents=true -Djava.library.path= -Xms512m -Xmx512m org.ap
ache.spark.deploy.master.Master --ip fluentd.alex.dev --port 7077 --webui-port 8080
Hope this helps.