Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't appear to work at all #10

Open
mdedetrich opened this issue Sep 10, 2015 · 5 comments
Open

Doesn't appear to work at all #10

mdedetrich opened this issue Sep 10, 2015 · 5 comments

Comments

@mdedetrich
Copy link

When using the uploaded test2.html, I am getting the following error with a file containing these html contents https://gist.github.com/mdedetrich/6dd23c5848922e5686dc

[2015-09-10 07:14:20 +0000] [12] [ERROR] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 130, in handle
    self.handle_request(listener, req, client, addr)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 171, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/wrappers.py", line 290, in application
    return f(*args[:-2] + (request,))(*args[-2:])
  File "/app.py", line 48, in application
    if options:
UnboundLocalError: local variable 'options' referenced before assignment

And when trying to post, I get the following error

ValueError: Invalid control character at: line 1 column 78 (char 77)
[2015-09-10 07:12:13 +0000] [12] [ERROR] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 130, in handle
    self.handle_request(listener, req, client, addr)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 171, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/local/lib/python2.7/dist-packages/werkzeug/wrappers.py", line 290, in application
    return f(*args[:-2] + (request,))(*args[-2:])
  File "/app.py", line 33, in application
    payload = json.loads(request.data)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)

In general, I can't seem to be able to get it to work at all, even with different HTML data

@dtoso-skymesh
Copy link

Your first error message occurs when you POST, and the Content-Type is NOT application/json, and you DON'T send any files in the body.

app.py could probably do with a third elif case at line 41 to report the error. For that matter, probably all of the simple returns should be Responses with status=400 and some relevant error message in the body (rather than 500 Internal Server Error as is now the case).

Your second error message occurs because you're using the JSON mode and you've sent something that isn't JSON in the body (most likely something that isn't in a valid character set). Refer to the JSON standard and/or use an appropriate library to encode your data-structure to JSON. Additionally app.py requires that the contents HTML be Base64 encoded. Did you do that?

@legramira
Copy link

Hi there,
I am trying to use the example from the readme file something like curl -X POST -vv -F 'file=test.html' http://XXX:80/ -o file.pdf , just as it is in the example, however, I am getting same issue with the following response :

  • Trying XXX...
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to XXX (XXX) port 80 (#0)

POST / HTTP/1.1
Host: XXX
User-Agent: curl/7.43.0
Accept: /
Content-Length: 149
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------029445e18cc4bad3

< HTTP/1.1 100 Continue
} [149 bytes data]
< HTTP/1.1 500 Internal Server Error
< Connection: close
< Content-Type: text/html
< Content-Length: 141
<
{ [141 bytes data]
100 290 100 141 100 149 56513 59719 --:--:-- --:--:-- --:--:-- 74500

  • Closing connection 0

where XXX is the ip of the docker, what it is going on?

Thanks in advance.

@dtoso-skymesh
Copy link

@legramira

It absolutely works. No problem at all.

Possible issue: you're sending your request to port 80.

  1. is the docker daemon actually listening on port 80?
  2. is port 80 connected to port 80 on the relevant docker container?
  3. is your firewall correctly forwarding traffic to containers?

The commandline looks wrong; you appear to be missing an @ from your CURL commandline filename.

If you correct all of the above, you can still:

  • check the logs on the container: sudo docker logs CONTAINERID
  • use tcpdump/wireshark to trace the HTTP conversation

@legramira
Copy link

Hi there,

Well I am posting this response message just in case someone has issues with the service, after checking all the points mentioned for dots-skymesh I end up checking the logs of the docker to finally get that the reason it has failing it was because as I copy a random web page on wikipedia I did not realise that that page was with an error of no resource found, I debug the page and buala!! it is working perfectly, so in a long short story, the htmltopdf works as long as the html runs without errors, maybe it seems clear now but it is well worth it to mention it, as browsers can load pages with errors but this service not.

@fred01
Copy link

fred01 commented Jan 30, 2018

I met some behavior when send json without content type. I think this issue should be corrected as something like "Return correct error code when no files and not proper content-type found". Also i think it would be better to handle any request without files as JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants