SSE (EventSource) Fails after about 150-200 records in Kubernetes Cluster

ImportWP Pro - WordPress XML & CSV Importer ImportWP Pro - WordPress XML & CSV Importer December 30, 2021
Login to reply
James Collings Support Agent commented privately
James Collings Support Agent
6 months ago

A newer version of import wp pro has been uploaded to codecanyon, this version once installed will require you to install the base plugin:

This import wp pro is the start of our wp cli integration:

wp importwp import <importer-id>

This will trigger an new import to run and you will see the progress in the terminal.

Stephen Vorwerk
6 months ago

I'll set you up on a lower environment today so you can torch it or whatever if you need to. 

Also, I saw the jc-importer GitHub repo was updated with some WP_CLI related updates. I was wondering if and when that will make it into the Pro version? I'm very excited about that as that would be an alternative approach.

James Collings Support Agent commented privately
Stephen Vorwerk commented privately
James Collings Support Agent
7 months ago

Hi Stephen,

ImportWP used to use event streams but due to the possibility of running on multiple hosting platforms not supporting output steam buffering this had to be removed and switched back to basic ajax reqests.

Are you able to provide wordpress access details to allow me to investivate what is happening?

You can enable logging by going into Setting / Tools > General Settings > Enable Debug Mode, Once enabled when viewing / editing an importer at the bottom right hand side of the importer there should be <> Show Debug, click this to view the importer logs, or view each importer log directly via:


Quick overview (might want to check the network tab in your browser to see if these urls are being cached via your server, or if a wordpress plugin is caching these requests such as object cache):

1. The importer on first run hits: /wp-json/iwp/v1/importer/{IMPORTER_ID}/init to create a new importer session
2. it then hits: /wp-json/iwp/v1/importer/{IMPORTER_ID}/run to import a chunk, it will then continue to hit that url until the importer completes or hits an error based on the JSON 's' key.


Stephen Vorwerk
7 months ago


I am working in WordPress VIP environment. This is an enterprise solution and I've had to make some modifications to the plugin to make it work appropriately in that environment, mainly just rewriting the Filesystem class, it seems to work well when I test locally where I'm mimicking the WP VIP environment, however, I am only running on a single container when I test locally. As soon as I transfer to WP VIP's servers, I've found that the SSE/EventSource stream fails after about 150-200 records, I'm thinking this is as a result of the requests being sent to different containers by the load balancer. 

The expected response to that would be to re-create the connection once failure occurs, but it doesn't seem to be doing that. I can't look at the JS as it's already compiled and no sourcemaps were provided, but it seems like you're using jQuery AJAX to execute the "run" endpoint, but I don't see the EventSource event handlers (ping/message/etc) anywhere. I could be missing them though IDK. 

More importantly, I need to have this run in a scheduled manner. I have not reviewed the scheduler/cron system you have in place, but it seems to be running into the same issue where it gets stuck after just a couple hundred in production. Again, locally, I've had no issues, so that's really the only thing I can think that is different is that WPVIP is running a kubernetes cluster and I'm just running a single docker container. Any ideas? I'm not really getting much in the way of logging either FYI and WP VIP doesn't give me direct server access so I'll have to try and figure out the best way to get some server side debug info. It would be helpful to know where to start though. Thank you!