Reputation: 30121
I have a single page FB Canvas app that is calling through the iframe a page I have hosted on Heroku.
Loading the page directly through my heroku link works no problem. However, when I try to load the page through the canvas app, it sometimes only loads half of the HTML. I need to spam refresh in order for the entire page to render correctly in the app.
I've checked my page against W3C validator and there are no syntax issues.
Is it Heroku just being slow? It loads pretty quickly when I access the url directly.
What could cause my page to just load halfway and stop?
Upvotes: 4
Views: 251
Reputation: 44939
I had this issue, too. I think it is related to the issue in this question: iFrame showing up Blank in Facebook Canvas App
If it is a Python app using Flask try this code: from werkzeug.wsgi import LimitedStream
class StreamConsumingMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
stream = LimitedStream(environ['wsgi.input'],
int(environ['CONTENT_LENGTH'] or 0))
environ['wsgi.input'] = stream
app_iter = self.app(environ, start_response)
try:
stream.exhaust()
for event in app_iter:
yield event
finally:
if hasattr(app_iter, 'close'):
app_iter.close()
Active it with this line:
app.wsgi_app = StreamConsumingMiddleware(app.wsgi_app)
Source: http://flask.pocoo.org/snippets/47/
Upvotes: 1
Reputation: 15907
I had this issue while using Heroku, but only for me and a colleague which were associated to the app as owner and tester respectively, other accounts could load the page just fine.
Testing the same app hosted via pagekite over a 24/3 ADSL works perfectly.
HTTPS or HTTP doesn't seem to matter. I'd say this is an Heroku issue.
EDIT: I'm not sure what happened, but the problem isn't there anymore. I can't think of anything that I did that fixed the issue, but I did many things both before and after the problem went away, such as cacheing remote data in the DB, and whatnot. I can't be certain anything of that helped or if it's some hidden issue in the Heroku infrastructure.
I contacted Heroku about the issue, by the time they came back to me, the issue had suddenly disappeared.
I have promised to get back with logs (both application and client HTTP/TCP logs), if you have this issue and can reproduce it, capture the logs and send it to Heroku support. Capturing TCP traffic can be done with wireshark and the Heroku application logs are available via heroku logs
.
Upvotes: 2