python-firebasin
python-firebasin copied to clipboard
Fail self.connect() under django
I use this lib to publish in real time some data inside a django (1.6) app. Running under the devserver, I get (several of these):
Exception in thread Thread-1256:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 808, in __bootstrap_inner
self.run()
File "/Users/mamcx/Proyectos/BestSeller/CloudApi/ENV/src/python-firebasin-master/firebasin/connection.py", line 40, in run
self.connect()
File "/Users/mamcx/Proyectos/BestSeller/CloudApi/ENV/src/python-firebasin-master/firebasin/connection.py", line 68, in connect
self.data.connect()
File "/Users/mamcx/Proyectos/BestSeller/CloudApi/ENV/lib/python2.7/site-packages/ws4py/client/__init__.py", line 209, in connect
self.sock.connect(self.bind_addr)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 333, in connect
self._real_connect(addr, False)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 320, in _real_connect
socket.connect(self, addr)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
gaierror: [Errno 8] nodename nor servname provided, or not known
I check the code on .connect, and see that before it it just sleep for a while, but NOT really check if the handshake succes:
# Just hang out until the handshake gives us the actual websocket URL
while not self.url:
time.sleep(0.1)
Hi Mamcx,
Thanks for contributing with this report!
I'm not familiar with Django, but I don't see anything in our code that would be causing this. Can you provide a complete code sample so I can debug further?
I have not figured how build a test that reproduce this outside django. This is my actual code:
from datetime import datetime
from django.http import HttpResponse, HttpResponseNotModified
from django.conf import settings
from firebasin import Firebase
def sendFirebase(schema, table, isDeleted, x_stationId):
server = Firebase('%s/%s/sync' % (settings.FIREBASE_URL, schema))
data = dict(
table=table,
date=datetime.now().isoformat(),
x_stationId=x_stationId,
isDeleted=isDeleted
)
server.set(data)
def syncRecord(request):
sendFirebase('sample', 'table', True, 1)
return HttpResponse()
This is running on the django devserver and with gunicorn.