I'm trying to install a production server for Django Channels application I've been running locally with success. However, when starting Daphne and reaching to the application via browser, I get an Internal Server Error from Daphne. Console output is as follows:
2021-08-07 11:57:09,584 DEBUG HTTP b'GET' request for ['127.0.0.1', 33566]
2021-08-07 11:57:10,071 ERROR Exception inside application: 'module' object is not callable
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/asgiref/compatibility.py", line 34, in new_application
instance = application(scope)
TypeError: 'module' object is not callable
2021-08-07 11:57:10,072 DEBUG HTTP 500 response started for ['127.0.0.1', 33566]
As the project/asgi.py might have some relevance here, it is below:
import os
import django
from django.core.asgi import get_asgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = "proj.settings"
django.setup()
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
import app.routing
application = ProtocolTypeRouter({
"http": get_asgi_application(),
"websocket": AuthMiddlewareStack(
URLRouter(
app.routing.websocket_urlpatterns
)
),
})
However, I've been poking around with the said asgi.py, and I have a feeling that at least the application variable does not have anything to do with this, as that block could be commented out with no impact on the error message.
Relevant packages:
channels 3.0.4
daphne 3.0.2
Django 3.2.6
Any ideas?
Related
When running the following commands, an error is thrown by the add command. The rdf4j framework is used for communicating with a graphdb Knowledge Base:
import org.eclipse.rdf4j.model.Model;
Model model;
//statements have been added to the model
public RepositoryConnection connection;
...
connection.add(model); <-- error is thrown
An error is thrown in add command
2022-01-24 09:46:02 [http-nio-8080-exec-5] ERROR restapi.SubmitRMService - unable to rollback transaction. HTTP error code 404
org.eclipse.rdf4j.repository.RepositoryException: unable to rollback transaction. HTTP error code 404
at org.eclipse.rdf4j.http.client.RDF4JProtocolSession.rollbackTransaction(RDF4JProtocolSession.java:786)
at org.eclipse.rdf4j.repository.http.HTTPRepositoryConnection.rollback(HTTPRepositoryConnection.java:354)
at org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection.conditionalRollback(AbstractRepositoryConnection.java:335)
at org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection.add(AbstractRepositoryConnection.java:379)
The code is running successfully in two other environments except one we are setting with kubernetes. We ensured that /opt/graphdb/home has write permissions.
Question: I just do not understand the 404 RepositoryException error. The code can successfully run queries before the .add(model), so the connection with the graphdb is ok.
localstack 12.5
dummy.py file for lambda hanlder
import sys
import requests
def handler(event, context):
print("Inside handler")
x = requests.get('http://localhost:9090/ping')
print(x.status_code)
return str(x.content)
In handler when i am calling get api which is in another container i am getting connection refused error.
Error:
"ConnectionError","errorMessage":"HTTPConnectionPool(host='localhost', port=9090): Max retries exceeded with url:
Caused by NewConnectionError('\u003curllib3.connection.HTTPConnection object at 0x7ff8185c8ad0\u003e: Failed to establish a new connection:
However with postman I am able to hit http://localhost:9090/ping API
Also If I replace x = requests.get('https://w3schools.com') then I am getting 200 .
The issue has been resolved by adding below env variable in localstack
LAMBDA_DOCKER_NETWORK="host"
I am trying to use twilio to send a text message...when I put the demo script in a texteditor, ave it as something.py and run it from terminal, I receive the text message.
However, when I copy and paste the same code into Spyder (Anaconda 3 environment, Python 3.8) I get the following error.
Here is the code:
from twilio.rest import Client
account_sid = 'xxx'
auth_token = 'xxx'
client = Client(account_sid, auth_token)
message = client.messages \
.create(
body="Test.",
from_='x',
to='xxx'
)
print(message.sid)
And here is there error:
File "xxx", line 14, in <module>
import twilio
ModuleNotFoundError: No module named 'twilio'
I have installed with pip, pip3, Conda, all that.
I'm not really used to this anaconda environment thing, but when I search for the package "twilio" the only thing that shows up is r-Twilio. I imagine this is something to do with the problem, but I've no idea. I tried creating a new environment with python 2.7 and again only saw the r-twilio thing.
I have a Windows server 2012 R2 and I downloaded and installed Ruby Hosting Packing from Microsoft Web Platform installer. When I try to run an existing website, I get the following error:
Error
Helicon Zoo module has caught up an error. Please see the details below.
Worker Status
The process was created
Windows error
The pipe has been ended. (ERROR CODE: 109)
Internal module error
message: Application backend read Error. type: ZooException file: App\Jobs\JobBase.cpp line: 531 version: 3.1.98.538
STDERR
[tid-5360004] Couldn't run bundler/setup: cannot load such file -- bundler/setup (String) [tid-5360004] cannot load such file -- rack (LoadError) C:/Zoo/Workers/ruby/lib/app.rb:84:in eval' C:/Ruby19/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire' (eval):1:in assure_rack' C:/Zoo/Workers/ruby/lib/app.rb:84:ineval' C:/Zoo/Workers/ruby/lib/app.rb:84:in assure_rack' C:/Zoo/Workers/ruby/lib/app.rb:23:inbuild_app' C:/Zoo/Workers/ruby/lib/app.rb:16:in initialize' C:/Zoo/Workers/ruby/lib/worker.rb:4:innew' C:/Zoo/Workers/ruby/lib/worker.rb:4:in initialize' C:/Zoo/Workers/ruby/zoorack.rb:30:innew' C:/Zoo/Workers/ruby/zoorack.rb:30:in <module:Zack>' C:/Zoo/Workers/ruby/zoorack.rb:12:in'
Any idea on how to fix this?
Thanks.
I created a askbot project by
askbot-setup
and
python manage.py syncdb # answered 'no' when asked to create superuser account
python manage.py migrate
I create a superuse from the shell:
from django.contrib.auth.models import User
User.objects.create_superuser('admin', admin#example.com', 'pass')
then I run the dev server and visit localhost from by browser
python manage.py runserver
Everything seems fine. But when I logout from the admin page, exception occurs:
AttributeError at /admin/logout/
'AnonymousUser' object has no attribute 'get_and_delete_messages'
Request Method: GET
Request URL: http://localhost:8000/admin/logout/
Django Version: 1.5
Exception Type: AttributeError
Exception Value:
'AnonymousUser' object has no attribute 'get_and_delete_messages'
Exception Location: /usr/local/lib/python2.7/dist-packages/askbot/user_messages/context_processors.py in user_messages, line 21
Python Executable: /usr/bin/python
Python Version: 2.7.4
Tracebacks:
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
140. response = response.render()
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py" in render
105. self.content = self.rendered_content
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py" in rendered_content
81. context = self.resolve_context(self.context_data)
File "/usr/local/lib/python2.7/dist-packages/django/template/response.py" in resolve_context
159. return RequestContext(self._request, context, current_app=self._current_app)
File "/usr/local/lib/python2.7/dist-packages/django/template/context.py" in __init__
179. self.update(processor(request))
File "/usr/local/lib/python2.7/dist-packages/askbot/user_messages/context_processors.py" in user_messages
21. messages = request.user.get_and_delete_messages()
Any help?
I found the solution.
I also posted this at http://askbot.org/en/question/11782/admin-logout-throw-exception/, using hailong as user name.
I solved that problem by modifying /usr/local/lib/python2.7/dist-packages/askbot/user_messages/context_processors.py
# messages = request.user.get_and_delete_messages() .... original, prox. line 22
messages = get_and_delete_messages(request)
Because I find function get_and_delete_messages only defined as a "standalone" function in that file, and never a method of some class. But it is used as request.user.get_and_delete_messages(). I assume it's a typo. If I am right, another typo is in /usr/local/lib/python2.7/dist-packages/askbot/user_messages/__init__.py (same usage).
Correct me if I am wrong. But it's likely my solution works.