EventStream Connection Error for EPUB

Howdy,
I’ve been trying for a few months now to make an EPUB export of a Pressbook but it keeps stalling out at chapter 19 of 65 and then the EventStream Connection Error appears.


image

Sometimes that happens as quickly as 11 seconds and as long as 40 seconds into the process. I have error log checked but I never get any notification of what happens.

I do not consistenly get the EventStream Connection Error so I do not believe it is my server, my CSS, or my use of H5p.

  • I’ve tried with a big book (A), and a small book (B). And get the same EventStream Connection Error.
  • I’ve EPUB exported on another book (C) with the same custom CSS as the big and small book and it exported just fine. The only difference of book C is that is does not contain any H5p.
  • I’ve successfully exported another very small book (D) that has 1 H5p element and no custom CSS.

What else can I try and how do I figure out what the error is that is causing the EventStream to lose connection?

Greatly appreciate any advice,
Cheers - Shar :star:

Hi Shar – can you share the URL for the book in question and copy the contents of the diagnostics page for the network you’re running this export on (will be at YOURNETWORKURL/wp-admin/options.php?page=pressbooks_diagnostics in reply to this thread? That might help folks reproduce or dig into what’s going wrong here.

Hi Steel,
“Sorry, you are not allowed to access this page.” is the message I get when trying to grab the network diagnostics info. Should I reach out to my network admin (aka librarian) for the diagnostics page info?

Here are my books:

  • Big Book A 477 pages digital PDF, web and PDF CSS. EventStream Connection error.
  • Small Book B where I test things out. Once upon a time when the book was still young I got an EPUB export from it, but no more. web and PDF CSS. EventStream Connection error.
  • Another Book C with web CSS only. successful EPUB.
  • Very Small Book D no custom CSS at all. successful EPUB.

Hope that helps y’all help me,
Cheers - Shar :star:

1 Like

Hi SharStar,

I think it’s going to be very important to talk to admin to get the network diagnostics page. I was seeing the Event Stream Error ALL THE TIME on my network, and I was trying to reproduce it well enough to get a detailed bug report for the Pressbooks team.

I had my Pressbooks network set up on PHP 8.0, when it should have been set up on PHP 7.4.

When I switched from PHP 8.0 → 7.4, all my event stream problems went away.

2 Likes

Hi Shar – what you shared was very helpful. Your books are on a network we host for the University of Washington, so this is probably going to be best handled as a premium support ticket, rather than here as a question in the forum for open source users/developers. I’ll open a support ticket for your issue and send an email to you and your network manager with our initial findings shortly. For future problems like this, we’d recommend taking them to your network manager(s) – they will have access to premium support with Pressbooks staff and you’ll be sure to get speedy, helpful support.

Yay!! Thanks much @SteelWagstaff ! :doughnut::bouquet:
cheers - Shar :star:

Hi Ed,
Oh I hope it’s the same kind of easy fix with the PHP. :crossed_fingers:
Cheers - Shar :star:

hi @SharStar I just sent you and your network manager an email. Hopefully you received it? It looks like the issue in both cases has to do with <video> elements with external src files. The EPUB export is trying to fetch the files and include them in the epub package as included assets, and I think it’s timing out because the files are too large. Video elements are currently not particularly well supported (or defined) in the EPUB specification: EPUB 3.3, and I think the preferred way to handle them would be to use embedded videos hosted on external streaming service rather than trying to package lots of video files with the EPUB.

Greetings @SteelWagstaff ,

Thanks for the diagnosis and I’ll pass on the advice to our media team about how we can stream videos with a built-in player (and use iframe embed) rather than relying on the browser’s player in the video tag.

Many thanks,
Shar :star:

1 Like

Hello, I am having the same error trying to export to PDF or Epub. I found this on the server LOG

[Thu Jun 29 11:35:59.140675 2023] [php:error] [pid 9515] [client 186.15.239.78:15395] PHP Fatal error:  Uncaught Error: Undefined constant "FS_CHMOD_FILE" in /var/www/pem/libros/wp-admin/includes/class-wp-filesystem-direct.php:164\nStack trace:\n#0 /var/www/pem/libros/wp-admin/includes/class-wp-filesystem-direct.php(86): WP_Filesystem_Direct->chmod()\n#1 /var/www/pem/libros/wp-content/plugins/pressbooks/inc/utility/namespace.php(1229): WP_Filesystem_Direct->put_contents()\n#2 /var/www/pem/libros/wp-content/plugins/pressbooks/inc/modules/export/prince/class-pdf.php(111): Pressbooks\\Utility\\put_contents()\n#3 /var/www/pem/libros/wp-content/plugins/pressbooks/inc/modules/export/class-export.php(779): Pressbooks\\Modules\\Export\\Prince\\Pdf->convert()\n#4 /var/www/pem/libros/wp-content/plugins/pressbooks/inc/class-eventstreams.php(71): Pressbooks\\Modules\\Export\\Export::exportGenerator()\n#5 /var/www/pem/libros/wp-content/plugins/pressbooks/inc/class-eventstreams.php(241): Pressbooks\\EventStreams->emit()\n#6 /var/www/pem/libros/wp-includes/class-wp-hook.php(308): Pressbooks\\EventStreams->exportBook()\n#7 /var/www/pem/libros/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()\n#8 /var/www/pem/libros/wp-includes/plugin.php(517): WP_Hook->do_action()\n#9 /var/www/pem/libros/wp-admin/admin-ajax.php(188): do_action()\n#10 {main}\n  thrown in /var/www/pem/libros/wp-admin/includes/class-wp-filesystem-direct.php on line 164, referer: https://multimedia.uned.ac.cr/pem/libros/manual/wp-admin/admin.php?page=pb_export

This seems to be the error:

Error: Undefined constant "FS_CHMOD_FILE" in /var/www/pem/libros/wp-admin/includes/class-wp-filesystem-direct.php

Do you know how this can be addressed? Do you think this can be due to be running on PHP8?

hi @marbaque I don’t think it’s a PHP 8 issue. We run all our hosted instances on PHP 8.1 and don’t see this error when we run exports. Not sure what the issue is as I don’t see it in our logs, but maybe others from the open source community have seen it and can advise?

Thank you @SteelWagstaff, we had an older version of pressbooks runnign on PHP 8… we updated pressbooks to 6.8.0, and now I don’t see the errors anymore. However, the PDF export keeps failing and the only message is “The export failed. Check the log for more details”, but the log shows no details.

@marbaque If you can’t find the error reports in your logs, you should be able to turn on email notifications for export errors. To do this, go to Settings->Export in your book dashboard and turn ‘Email Validation Logs’ on. A notification will be sent to the email address of the person who created the export with the errors.

Thank you, @SteelWagstaff but as strange as it sounds there are no errors in the log, and it is not sending any email notifications when trying to export to PDF.

I do get the email notification with errors and warnings when exporting to other formats.