joedayz
Posts: 11
Joined: Tue May 23, 2023 3:55 pm

Using http export module with HTTPS

Hi guys, I installed a high chart export module in AWS. Everything is ok when all is HTTP, but when I configure https, the images return the error:

"an error occurred when rendering the chart: SyntaxError: Unexpected token S in JSON at position 0"

And in the log, I can see the error:

Tue May 23 2023 15:50:54 GMT+0000 (UTC) [error] phantom worker 1 unexpected data - SyntaxError: Use of reserved word 'let' in strict mode...
{"data":"iVBORw0KGgoAAAANSUhEUgAAAlgAAAGQCAYAAAByNR6YAAAACXBIWXMAAAsTAAALEwEAmpwYAAAgAElEQVR4nO3dedQmVX3g8S9rszQ2zdYgIM3SEG0RSNQIicqJBm...

Some idea about it error, please?
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Using http export module with HTTPS

Hi,

Welcome to our forum & thanks for the question!

I believe that the same problem was reported here: viewtopic.php?f=9&t=50838

The problem stems from the fact that Highcharts v11 now uses ES6 (and Highcharts v10 was still in ES5 standard) so now let and const are used instead of vars. PhantomJS is now deprecated and has no support for standards higher than ES5.

I provided 3 solutions to this problem in the topic I've linked.

Try them out and please let me know if it works for you.

Best regards!
Jakub
Highcharts Developer
joedayz
Posts: 11
Joined: Tue May 23, 2023 3:55 pm

Re: Using http export module with HTTPS

I continue with problems. I am using docker:

FROM node:carbon

ENV ACCEPT_HIGHCHARTS_LICENSE="1"
ENV HIGHCHARTS_USE_STYLED="1"
ENV HIGHCHARTS_USE_MAPS="1"
ENV HIGHCHARTS_USE_GANTT="1"

RUN npm install highcharts-export-server -g --unsafe-perm

RUN git clone https://github.com/mschoettle/node-export-server
RUN cd node-export-server && npm install && npm link

RUN node /usr/local/lib/node_modules/highcharts-export-server/build.js
RUN npm install

WORKDIR /usr/share/fonts/truetype

ADD fonts/OpenSans-Regular.ttf OpenSans-Regular.ttf
ADD fonts/OpenSans-Light.ttf OpenSans-Light.ttf
ADD fonts/OpenSans-Semibold.ttf OpenSans-Semibold.ttf
ADD fonts/OpenSans-Bold.ttf OpenSans-Bold.ttf
ADD fonts/OpenSans-ExtraBold.ttf OpenSans-ExtraBold.ttf
ADD fonts/OpenSans-Italic.ttf OpenSans-Italic.ttf
ADD fonts/OpenSans-LightItalic.ttf OpenSans-LightItalic.ttf
ADD fonts/OpenSans-BoldItalic.ttf OpenSans-BoldItalic.ttf
ADD fonts/OpenSans-SemiboldItalic.ttf OpenSans-SemiboldItalic.ttf
ADD fonts/OpenSans-ExtraBoldItalic.ttf OpenSans-ExtraBoldItalic.ttf

# /usr/local/lib/node_modules/highcharts-export-server
COPY ./api /api
COPY start.sh /api/start.sh

WORKDIR /api
RUN npm install && chmod +x ./start.sh

EXPOSE 8080
CMD ./start.sh
#ENTRYPOINT ["highcharts-export-server", "--enableServer", "1", "--port", "8080", "--logLevel", "4"]



In Local, the execution is ok.

curl -H "Content-Type: application/json" -X POST -d '{"infile":{"title": {"text": "Steep Chart"}, "xAxis": {"categories": ["Jan", "Feb", "Mar"]}, "series": [{"data": [29.9, 71.5, 106.4]}]}}' localhost:8089 -o testchart.png. ---> works!!!!

But when I deployed it in my server, https://myserver.com:8080 it returns:

5/25/2023, 10:24:08 PM GMT-5 Fri May 26 2023 03:24:08 GMT+0000 (UTC) [error] work c0840407347943578ef121aa33871522 could not be completed, sending: an error occured when rendering the chart: SyntaxError: Unexpected token S in JSON at position 0 1d646814e076404cb9e63a6e332c0ae5 hightchartserver-app
5/25/2023, 10:24:08 PM GMT-5 Fri May 26 2023 03:24:08 GMT+0000 (UTC) [error] phantom worker 2 unexpected data - SyntaxError: Use of reserved word 'let' in strict mode 1d646814e076404cb9e63a6e332c0ae5 hightchartserver-app
5/25/2023, 10:24:08 PM GMT-5 phantomjs://code/worker.js:658 in loop 1d646814e076404cb9e63a6e332c0ae5 hightchartserver-app
5/25/2023, 10:24:08 PM GMT-5 {"data":"iVBORw0KGgoAAAANSUhEUgAAAlgAAAGQCAYAAAByNR6YAAAACXBIWXMAAAsTAAALEwEAmpwYAAAgAElEQVR4nO3dedQmVX3g8S9rszQ2zdYgIM3SEG0RSNQIicqJBmEguILomGiQIRpnopLEMcmcmJkxjkajMYmaqBlBiBOViERZbI3BBNAoGONKXFqUtQFBaWQR5Jk/fvWct9771nLrqXre9fs55zndb91b9966t+rWrR0kSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSZIkSdJwRj1/Gs5BwBuBa4AfAg8BPwa+B3wGeAfw


For this reason, the title of my question is about HTTPS.

Maybe I need to add some extra configuration.

Jose
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Using http export module with HTTPS

Hi,

Thanks!

When it comes to this error, it does not make any difference whether it's HTTP or HTTPS. However, you may have a different node-export-server repo locally and a different one running in your production environment.

This error stems from the fact that the your node-export-server repository that you have in your docker settings (RUN git clone ...) does not include ES5 Highcharts scripts.

If you clone this: https://github.com/highcharts/node-expo ... abd37fd5ec and you check out the build.js file you'll notice that a special case was added which sends CDN requests to only fetch ES5 scripts.

That's not true for your repository.

If you clone the newest version of node-export-server from our GitHub then this error should disappear.

Let me know if it works.

Best regards!
Jakub
Highcharts Developer
joedayz
Posts: 11
Joined: Tue May 23, 2023 3:55 pm

Re: Using http export module with HTTPS

Hi @jakub.s, thanks for your answer:

I did the change of repo in the Dockerfile (https://gist.github.com/joedayz/7eb9567 ... b1c1e7498f) and the log (https://gist.github.com/joedayz/1ba3d49 ... 5c3965b071).

Next, I created a container with it new version:

Code: Select all

docker run -itd --name highcharts -p 8089:8080  -p 7009:7000 highchart-export-server
Finally, I did a test in postman and the same error:

an error occured when rendering the chart: SyntaxError: Unexpected token S in JSON at position 0

The docker log of the container shows the following:

Mon May 29 2023 01:20:45 GMT+0000 (UTC) [error] phantom worker 3 unexpected data - SyntaxError: Unexpected token ','

phantomjs://code/worker.js:658 in loop
{"data":"iVBORw0KGgoAAAANSUhEUgAAAlgAAAGQCAYAAAByNR6YAAAACXBIWXMAAAsTAAALEwEAmpw
...

Now, I have the same error in my local desktop. If you have some idea about of that is missing, please, let me know.

Jose
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Using http export module with HTTPS

Hi,

I cloned the repository and I get the same error. Unfortunately, I see that some new things have been merged into master which cause this error.

Please give me some time to investigate this.

I'll reach out to you this week (hopefully tomorrow) to propose a solution to this problem.

Kind regards
Jakub
Highcharts Developer
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Using http export module with HTTPS

Hi,

Unfortunately it's difficult to find the cause of the problem as multiple changes have been made since the last publish.

The only workaround I can propose to you for now is to choose the 10.3.3 version of Highcharts for the highcharts-export-server. You can do this by setting the HIGHCHARTS_VERSION environment variable to 10.3.3.

With this version you should be able to install the highcharts-export-server from npm as usual (you do not have to play with git clone). This way you'll have a ES5 version of Highcharts so we'll avoid the first error that brought you here (Use of reserved word 'let').

If you install the package from NPM and you do not get the first error related to the ECMAScript standard then you should not encounter the latest problem you've presented in this thread (Unexpected token ',').

I'm aware that downgrading is not a perfect solution, but please know that we're currently working on solving this problem. I'll keep you posted on this issue.

In the meantime do not hesitate to ask in case you have any more questions. Also, please let me know if this works for you.

Best regards!
Jakub
Highcharts Developer
joedayz
Posts: 11
Joined: Tue May 23, 2023 3:55 pm

Re: Using http export module with HTTPS

The version 10.3.3 works with these changes:

Code: Select all

[b]FROM node:14[/b]

ENV ACCEPT_HIGHCHARTS_LICENSE="1"
ENV HIGHCHARTS_USE_STYLED="1"
ENV HIGHCHARTS_USE_MAPS="1"
ENV HIGHCHARTS_USE_GANTT="1"
[b]ENV HIGHCHARTS_VERSION="10.3.3"[/b]
ENV OPENSSL_CONF=/dev/null

RUN npm install highcharts-export-server -g --unsafe-perm

RUN node /usr/local/lib/node_modules/highcharts-export-server/build.js
RUN npm install
...

In the log I got these lines:
Could not find 10.3.3/adapters/standalone-framework.js
The version you requested is invalid!
Please try again
Agree to the license terms? y/n: (no)
> [email protected] postinstall /usr/local/lib/node_modules/highcharts-export-server
> node ./post.build.js
I have a license, but, How can I accept the license terms?

Because, when execute it curl command:

Code: Select all

curl -H "Content-Type: application/json" -X POST -d '{"infile":{"title": {"text": "Steep Chart"}, "xAxis": {"categories": ["Jan", "Feb", "Mar"]}, "series": [{"data": [29.9, 71.5, 106.4]}]}}' localhost:9089 -o testchart.png

I got the following error:
Export server not configured.
Please complete the configuration by running node build.js in the export server root.
If you installed by running npm install -g highcharts-export-server and declined the license agreement, you need to re-install to confirm.
This is the unique problem right now.

Thanks for your help

Jose
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Using http export module with HTTPS

Hi Jose,

Sorry for the late response. From what I can see in your log you do not accept the license terms or the default option "no" is chosen.

1. I'm not sure why that happens, I'll talk to our Lead Export Server Developer and look deeper into it. For now, a not perfect but simple workaround I see to this is modifying the default value of agree.default to 'yes' (in node-export-server/build.js file in the "schema" variable). If you do it you'll automatically agree to the license terms.

2. I tested a few things and noticed another issue which also appears in your case (Could not find 10.3.3/adapters/standalone-framework.js) which might cause some problems. To fix this you could comment line 208 of build.js (it was fixed in this commit: https://github.com/highcharts/node-expo ... abd37fd5ec). The problem stems from the fact that there is no script like that in our CDN: https://code.highcharts.com/10.3.3/adap ... amework.js and it tricks Highcharts-Export-Server to believe that the version you have given (10.3.3) is incorrect even though it is definitely correct. By commenting the cdnLegacy line you make sure that the version 10.3.3 is accepted.

3. Also, it might be related to this issue: https://github.com/highcharts/node-expo ... issues/358
You could just try running npm i, npm link, node build.js (the commands given in the last post under this issue).

We are aware that the product is not perfect yet and there are some issues that need to be solved, but please know that we're working on making it better & better and please do not hesitate to ask in case any questions arise. I'll try to help as fast as I can.

Kind regards!
Jakub
Highcharts Developer
joedayz
Posts: 11
Joined: Tue May 23, 2023 3:55 pm

Re: Using http export module with HTTPS

Thanks, it works!

I documented all in it link: https://blog.joedayz.pe/2023/06/highcha ... erver.html

I will be working with version 10.3.3 until the next version will be released!

Cheers.

Jose
jakub.s
Posts: 1164
Joined: Fri Dec 16, 2022 11:45 am

Re: Using http export module with HTTPS

Wow, that's amazing, thank you very much! This post will be very helpful for a lot of users.

I'll remember to let you know when we make any progress on the puppeteer version which will surely have support for Highcharts 11.

Best regards!
Jakub
Highcharts Developer
nafi_ullah
Posts: 3
Joined: Sun Apr 09, 2023 4:29 pm

Re: Using http export module with HTTPS

To resolve the issue, you can try updating the high chart export module to the latest version. Additionally, ensure that the version of JavaScript running in your environment supports the features used by the module.

If the issue persists, it would be helpful to consult the documentation or support resources for the specific high chart export module you're using. They can provide more specific guidance on troubleshooting HTTPS configuration and compatibility issues.

Return to “Highcharts Usage”