Publish/Book export error ("Could not send the publishing request")
  • Vote Up0Vote Down JorisJoris
    Posts: 3Member




    Hi everyone!

    I followed along this nice tutorial to setup my own booktype version for testing purpose. I did everything exactly as explained in the tutorial (just didn't installed the outgoing mail server for email notifications yet), but still get an error when I press the "Publish" button to export a book (please see the log excerpt).

    Could someone support? 

    Cheers,

    Joris


    *** START FILE: /logs/booktype-celery.error.log ***

    'side_margin': u'20', u'bleed_size': u'', u'size': u'A4'}}}}}

    [2016-06-30 15:44:32,744: INFO/Worker-3] Starting new HTTP connection (1): booktype.electricelephantpublishing.de

    [2016-06-30 15:44:33,438: ERROR/Worker-3] Could not load JSON data.

    Traceback (most recent call last):

      File "/usr/local/src/booktype/lib/booktype/utils/download.py", line 45, in fetch_url

        dta = req.json()

      File "/usr/lib/python2.7/dist-packages/requests/models.py", line 793, in json

        return json.loads(self.text, **kwargs)

      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 384, in raw_decode

        raise ValueError("No JSON object could be decoded")

    ValueError: No JSON object could be decoded

    [2016-06-30 15:44:33,443: ERROR/Worker-3] Could not send the publishing request to [http://booktype.electricelephantpublishing.de/_convert/]

    [2016-06-30 15:44:33,460: INFO/MainProcess] Task booktype.apps.edit.tasks.publish_book[29987051-7482-4ee4-bfa5-336fccded577] succeeded in 0.861105453001s: None

    [2016-06-30 15:45:50,948: INFO/MainProcess] Received task: booktype.apps.edit.tasks.publish_book[506047cd-6ab7-4b49-8260-51c217d58b19]

    [2016-06-30 15:45:50,956: DEBUG/Worker-1] {'username': u'admin', 'bookid': u'1', 'clientid': u'21', 'sputnikid': u'ps1a24y29zubxnm1euwoehtovnsnnvs8:21', 'version': u'1.0', 'formats': [u'epub']}

    [2016-06-30 15:45:51,021: DEBUG/Worker-1] {'input': 'input.epub', 'assets': {'input.epub': u'http://booktype.electricelephantpublishing.de/brainfood/_export/', 'epub_cover_image': 'http://booktype.electricelephantpublishing.de/brainfood/_cover/218bd41b7ed0bf62238f00ed30bd202ebb4df447/cover.jpg'}, 'outputs': {u'epub': {'profile': u'epub', 'output': 'brainfood_2016-06-30_15-45-51.epub', 'config': {'cover_image': 'epub_cover_image', 'theme': {'id': u'custom', 'custom': u'{"fontP": "serif", "lineHeightP": 100, "fontH1": "serif", "fontSizeH4": 100, "fontSizeH2": 140, "fontSizeH3": 120, "fontSizeH1": 160, "indentP": 0, "alignH1": "left", "colorH1": "000000"}'}, 'project_id': u'brainfood', 'settings': {u'cover_image': u'218bd41b7ed0bf62238f00ed30bd202ebb4df447/cover.jpg', u'styling': u''}}}}}

    [2016-06-30 15:45:51,038: INFO/Worker-1] Starting new HTTP connection (1): booktype.electricelephantpublishing.de

    [2016-06-30 15:45:51,663: ERROR/Worker-1] Could not load JSON data.

    Traceback (most recent call last):

      File "/usr/local/src/booktype/lib/booktype/utils/download.py", line 45, in fetch_url

        dta = req.json()

      File "/usr/lib/python2.7/dist-packages/requests/models.py", line 793, in json

        return json.loads(self.text, **kwargs)

      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 384, in raw_decode

     raise ValueError("No JSON object could be decoded")

    ValueError: No JSON object could be decoded

    [2016-06-30 15:45:51,665: ERROR/Worker-1] Could not send the publishing request to [http://booktype.electricelephantpublishing.de/_convert/]

    [2016-06-30 15:45:51,676: INFO/MainProcess] Task booktype.apps.edit.tasks.publish_book[506047cd-6ab7-4b49-8260-51c217d58b19] succeeded in 0.724731087999s: None

    *** END FILE: /logs/booktype-celery.error.log ***

    Post edited by Joris at 2016-06-30 10:48:36
  • 3 Comments sorted by
  • Vote Up1Vote Down Daniel JamesDaniel James
    Posts: 844Member, Sourcefabric Team
    Hi Joris, I see that http://booktype.electricelephantpublishing.de/_convert/ is a valid URL. You might try changing the value of EXPORT_ALLOWED_HOSTS to:


    EXPORT_ALLOWED_HOSTS = ['127.0.0.1', '*']


    in the file:

    /var/www/booktype/instance1/instance1_site/settings/base.py
    I would then suggest running the commands:
    sudo supervisorctl restart all
    sudo service apache2 reload
    This will restart the Celery workers and reload the Apache configuration. Then try publishing the EPUB again.

    Let us know how you get on!

    Daniel
  • Vote Up0Vote Down JorisJoris
    Posts: 3Member
    Hi Daniel,

    I did what you suggested and it worked! Thank you very much for your support.

    Cheers,
    Joris

    I came across a follow-up error while exporting the .mobi version on a book.
    The .mobi file export runs and an export prompt is visible but the "MOBI" button to download the file is deactivated.

    Could you help? :)

    *** START LOG: booktype-celery.error.log ***
    [2016-07-01 11:11:45,094: INFO/MainProcess] Received task: booktype.apps.edit.tasks.publish_book[eb37438b-de87-49
    ab-9d83-4c812a828574]
    [2016-07-01 11:11:45,096: DEBUG/Worker-8] {'username': u'admin', 'bookid': u'1', 'clientid': u'29', 'sputnikid': u'ps1a24y29zubxnm1euwoehtovnsnnvs8:29', 'version': u'1.0', 'formats': [u'mobi']}
    [2016-07-01 11:11:45,137: DEBUG/Worker-8] {'input': 'input.epub', 'assets': {'mobi_cover_image': 'http://booktype.electricelephantpublishing.de/brainfood/_cover/218bd41b7ed0bf62238f00ed30bd202ebb4df447/cover.jpg', 'input.epub': u'http://booktype.electricelephantpublishing.de/brainfood/_export/'}, 'outputs': {u'mobi': {'profile': u'mobi', 'output': 'brainfood_2016-07-01_11-11-45.mobi', 'config': {'cover_image': 'mobi_cover_image', 'theme': {'id': u'custom', 'custom': u'{"fontP": "serif", "lineHeightP": 100, "fontH1": "serif", "fontSizeH4": 100, "fontSizeH2": 140, "fontSizeH3": 120, "fontSizeH1": 160, "indentP": 0, "alignH1": "left", "colorH1": "000000"}'}, 'project_id': u'brainfood', 'settings': {u'cover_image': u'218bd41b7ed0bf62238f00ed30bd202ebb4df447/cover.jpg', u'styling': u''}}}}}
    [2016-07-01 11:11:45,148: INFO/Worker-8] Starting new HTTP connection (1): booktype.electricelephantpublishing.de
    [2016-07-01 11:11:45,190: INFO/MainProcess] Received task: convert[bf490d78-f18a-4c2b-b886-0feaa902c506]
    [2016-07-01 11:11:45,225: INFO/Worker-3] Starting new HTTP connection (1): booktype.electricelephantpublishing.de
    [2016-07-01 11:11:45,528: DEBUG/Worker-8] Waiting for the task d52c00f2-3f6b-11e6-bc3f-040113c28b01 to finish. Will wait for 90 seconds.
    [2016-07-01 11:11:45,530: INFO/Worker-8] Starting new HTTP connection (1): booktype.electricelephantpublishing.de
    [2016-07-01 11:11:45,819: INFO/Worker-3] Starting new HTTP connection (1): booktype.electricelephantpublishing.de
    /usr/local/lib/python2.7/dist-packages/celery/result.py:45: RuntimeWarning: Never call result.get() within a task!

    In Celery 3.2 this will result in an exception being
    raised instead of just being a warning.

      warnings.warn(RuntimeWarning(E_WOULDBLOCK))

    [2016-07-01 11:11:46,326: INFO/MainProcess] Received task: convert_one[mobi:9d364073-2f40-4db2-b07a-b635c343f012]
    [2016-07-01 11:11:46,331: DEBUG/Worker-6] [EPUB] EpubConverter.convert
    [2016-07-01 11:11:46,324: WARNING/Worker-3] /usr/local/lib/python2.7/dist-packages/celery/result.py:45: RuntimeWarning: Never call result.get() within a task!

    In Celery 3.2 this will result in an exception being
    raised instead of just being a warning.

      warnings.warn(RuntimeWarning(E_WOULDBLOCK))

    [2016-07-01 11:11:46,334: DEBUG/Worker-6] [EPUB] Edit metadata
    [2016-07-01 11:11:46,335: DEBUG/Worker-6] [EPUB] Copy items
    [2016-07-01 11:11:46,339: DEBUG/Worker-6] [EPUB] Make navigation
    [2016-07-01 11:11:46,342: DEBUG/Worker-6] [EPUB] Add cover
    [2016-07-01 11:11:46,346: DEBUG/Worker-6] [EPUB] Setting writer plugins and options
    [2016-07-01 11:11:46,359: DEBUG/Worker-6] [EPUB] Writer
    [2016-07-01 11:11:46,360: DEBUG/Worker-6] [EPUB] Process
    [2016-07-01 11:11:46,361: DEBUG/Worker-6] [EPUB] Write
    [2016-07-01 11:11:46,398: INFO/Worker-8] Starting new HTTP connection (1): booktype.electricelephantpublishing.de
    [2016-07-01 11:11:46,403: DEBUG/Worker-6] [END] EPUBConverter.convert
    [2016-07-01 11:11:46,403: INFO/Worker-6] Conversion lasted 0:00:00.071650.
    [2016-07-01 11:11:46,410: ERROR/Worker-6] Error while running the command: ['ebook-convert', Path('/var/www/booktype/instance1/data/tmp/d52c00f2-3f6b-11e6-bc3f-040113c28b01/mobi/brainfood_2016-07-01_11-11-45.mobi.epub'), Path('/var/www/booktype/instance1/data/tmp/d52c00f2-3f6b-11e6-bc3f-040113c28b01/mobi/brainfood_2016-07-01_11-11-45.mobi')]
    [2016-07-01 11:11:46,428: ERROR/MainProcess] Task convert_one[mobi:9d364073-2f40-4db2-b07a-b635c343f012] raised unexpected: OSError(2, 'No such file or directory')
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 240, in trace_task
        R = retval = fun(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 438, in __protected_call__
        return self.run(*args, **kwargs)
      File "/usr/local/src/booktype/lib/booktype/apps/convert/tasks.py", line 49, in decorated_func
        return func(request, *args, **kwargs)
      File "/usr/local/src/booktype/lib/booktype/apps/convert/tasks.py", line 65, in convert_one
        result = run_conversion(*args, **kwargs)
      File "/usr/local/src/booktype/lib/booktype/convert/runner.py", line 58, in run_conversion
        conversion_result = converter.convert(book, output)
      File "/usr/local/src/booktype/lib/booktype/convert/mobi/converter.py", line 48, in convert
        rc, out, err = run_command(command)
      File "/usr/local/src/booktype/lib/booktype/convert/utils/__init__.py", line 28, in run_command
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
        errread, errwrite)
      File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
        raise child_exception
    OSError: [Errno 2] No such file or directory
    [2016-07-01 11:11:46,865: INFO/MainProcess] Task convert[bf490d78-f18a-4c2b-b886-0feaa902c506] succeeded in 1.647033104s: {u'mobi:9d364073-2f40-4db2-b07a-b635c343f012': <AsyncResult: mobi:9d364073-2f40-4db2-b07a-b635c343f012>}
    [2016-07-01 11:11:47,164: INFO/Worker-8] Starting new HTTP connection (1): booktype.electricelephantpublishing.de
    [2016-07-01 11:11:47,441: INFO/Worker-8] Successfully received status of the conversion task d52c00f2-3f6b-11e6-bc3f-040113c28b01.
    [2016-07-01 11:11:47,448: INFO/MainProcess] Task booktype.apps.edit.tasks.publish_book[eb37438b-de87-49ab-9d83-4c812a828574] succeeded in 2.352403485s: None

    *** END LOG: booktype-celery.error.log ***
    Post edited by Joris at 2016-07-01 05:13:05
  • Vote Up0Vote Down Daniel JamesDaniel James
    Posts: 844Member, Sourcefabric Team
    Hi Joris, glad to hear you got the EPUB export working. I think this error was due to switching between IP address and hostname after the install.

    The MOBI error is different, as export of MOBI files requires an extra step that we do not cover in the DigitalOcean tutorial. In the base.py file you will see the default .mobi converter is calibre, but it is also possible to use the kindlegen tool:

    # MOBI EXPORT
    MOBI_CONVERT = "calibre"

    So if you want to use calibre, you need to use the command to install it:

    sudo apt-get install calibre

    Then the 'No such file or directory' in the log should go away.

    Cheers!

    Daniel