Firebase Streaming using Python, connection times out when there is huge amount of data under the child.
<p>I am listening to data from firebase, under a path that contains enormous amount of data, using this library <a href="https://github.com/andrewsosa001/firebase-python-streaming" rel="nofollow">firebase-python-streaming</a>.However every time I start streaming, it gets hung on the call and nothing is returned leading to an eventual timeout. However if I try it on a shorter path it works, in the first call returns all the data inside the child, followed by changes if any made in the database. </p>

<pre><code>def p(x):
print x

# Firebase object
fb = Firebase('https://myfirebase.firebaseio.com/')
custom_callback = fb.child("views").listener(p)

# Start and stop the stream using the following
custom_callback.start()
raw_input("ENTER to stop...")
custom_callback.stop()enter code here
</code></pre>

<p>On running the streamer, the command line stays stuck here in case of large data</p>

<pre><code>ENTER to stop...
</code></pre>

<p>It stays stuck there and eventually times out. I have used other libraries as well such as pyrebase, and pyfirebase with the same result.
I think it has to do with the large amount of data I am trying to stream in the first iteration.
Is there any hack or solution to fix this?</p>

<p>If you get problems because of the large amount of data you're trying to retrieve, the solution will be to retrieve less data.</p>

<p>One way to do this would be to listen to a point <strong>lower</strong> in your database tree. E.g.</p>

<pre><code>custom_callback = fb.child("views/201609").listener(p)
</code></pre>

<p>This requires you to modify you data structure. You'll find that a common theme when using NoSQL databases: you need to model your data for the way you application wants to consume it.</p>

<p>Alternatively, you can request only the most recent items from your database. I'm not exactly sure how your Python library handles these, but on the REST API this would be something like:</p>

<pre><code>https://myfirebase.firebaseio.com/views.json?orderBy=$key&amp;limitToLast=100
</code></pre>

python firebase listener firebase-database