在本地使用 pdftron webviewer 服务器时无法加载 pdf 文件

Can't load pdf file while using pdftron webviewer server in local

我正在尝试将 webviewer 与 webviewer 服务器一起使用。需要传递的 cookie 中有安全信息。在 docker-compose 中设置了要转发的 属性。

 webviewer:
    container_name: webviewer-server
    image: pdftron/webviewer-server:latest
    ports:
      - "8090:8090"
    environment:
#      - INCLUDE_DEMO='true'
      - TRN_FORWARD_CLIENT_COOKIES='true'
      - TRN_DEBUG_MODE='true'

查看从 webviewer 服务器获取信息的日志。 它收到必要的 cookie 信息以调用服务器。但是当进行校准时,连接被拒绝。 这是错误消息。

| Creating WS connection at endpoint ...
webviewer-server | 09-Apr-2020 14:38:22.554 INFO [http-apr-8090-exec-2] com.pdftron.server.ConnectionService$WebsocketConnection.<init> Creating WS connection 31204549507251, 1 connections total
webviewer-server | 09-Apr-2020 14:38:22.804 INFO [http-apr-8090-exec-10] com.pdftron.server.BlackBoxMessenger.accessLog 31204549507251 accessing http://localhost:8080/secured/fileContent/2?downloadFile=false for page info
webviewer-server | 09-Apr-2020 14:38:22.805 INFO [http-apr-8090-exec-10] com.pdftron.server.ServerJob.<init> Starting pages: /usr/local/apache-tomcat/static_data/Image/Fetched/4XAIzCDauayBoDmSiovlh4f6tcgVwzeZ4NVrpZjKxUA=2.pdf_dir/pageinfo.json
webviewer-server | 09-Apr-2020 14:38:22.806 INFO [http-apr-8090-exec-10] com.pdftron.server.ServerJob.<init> Starting image: /usr/local/apache-tomcat/static_data/Image/Fetched/4XAIzCDauayBoDmSiovlh4f6tcgVwzeZ4NVrpZjKxUA=2.pdf_dir/pageimg0.jpg
webviewer-server | 09-Apr-2020 14:38:22.806 INFO [pool-2-thread-12] com.pdftron.server.DocReference.fetchLocalBlocking needs_fetch: http://localhost:8080/secured/fileContent/2?downloadFile=false
webviewer-server | 09-Apr-2020 14:38:22.807 INFO [pool-2-thread-7] com.pdftron.server.DocReference.fetchLocalBlocking needs_fetch: http://localhost:8080/secured/fileContent/2?downloadFile=false
webviewer-server | 09-Apr-2020 14:38:22.807 INFO [pool-2-thread-12] com.pdftron.server.DocManagement.createFetchThread Adding task http://localhost:8080/secured/fileContent/2?downloadFile=falseto fetch queue
webviewer-server | 09-Apr-2020 14:38:22.810 INFO [pool-5-thread-1] com.pdftron.server.DocManagement$DocFetchTask.doFetch Kicking off potential fetch of http://localhost:8080/secured/fileContent/2?downloadFile=false
webviewer-server | 09-Apr-2020 14:38:22.810 INFO [pool-5-thread-1] com.pdftron.server.DocManagement.constructConnection setting http://localhost:8080/secured/fileContent/2?downloadFile=false custom header Cookie: Idea-b611af61=fc8272b5-372b-48b6-a200-03b7204be819; fingerprint=e68d8c46-0988-4ac0-9154-1aac1be432b0; access_token=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJsY2VyZ2ljK2JAZXJ5Y2UuY29tIiwiY2xpZW50SWQiOiJXRUJfQVBQTElDQVRJT04iLCJ1c2VySWQiOjIsImlzcyI6ImVyeWNlLmNvbSIsImp0aSI6IjkwZDE1ZDBkLTU4ZTctNGM4YS1hMTBlLTdiYjlmZTA1Y2ZhYSIsImlhdCI6MTU4NjQ0Mjg2NSwiZXhwIjoxNTg2NDQzMTY1fQ.zFqrjvEZTwe9QC5azI1HrNG4wbxGrydGdUVli0XmRmf7wv9-KKBFeNsljluz9o7lSXPsAzdrlq5Bhzd3hKk1aw; refresh_token=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJsY2VyZ2ljK2JAZXJ5Y2UuY29tIiwiY2xpZW50SWQiOiJXRUJfQVBQTElDQVRJT04iLCJ1c2VySWQiOjIsImlzcyI6ImVyeWNlLmNvbSIsImp0aSI6IjAyYjc4MjRkLTJjMDAtNDRkNi04ZTY2LWM1OGU0NmM4ODE5YiIsImlhdCI6MTU4NjQ0Mjg2NSwiZXhwIjoxNTg2ODc0ODY1fQ.60jj88_lSH_ZngtfAt6EyzfMzZltCTNxLRYHxfGCUrEKd46O6b9bxCSS23_w4vHvecJebYOtpPgUlD0kYLeiHw; JSESSIONID=CB48A60A9DE9EAFBC94F9C4A98089EB3
webviewer-server | 09-Apr-2020 14:38:22.812 WARNING [pool-2-thread-1] com.pdftron.server.ServerJob.run During job id (/usr/local/apache-tomcat/static_data/Image/Fetched/4XAIzCDauayBoDmSiovlh4f6tcgVwzeZ4NVrpZjKxUA=2.pdf_dir/pageimg0.jpg):
webviewer-server | Exception during job run of type image
webviewer-server |  java.lang.Exception: WebViewer Server complete job (/usr/local/apache-tomcat/static_data/Image/Fetched/4XAIzCDauayBoDmSiovlh4f6tcgVwzeZ4NVrpZjKxUA=2.pdf_dir/pageimg0.jpg) failed: unable to complete fetch of http://localhost:8080/secured/fileContent/2?downloadFile=false
webviewer-server | Connection refused (Connection refused)
webviewer-server |      at com.pdftron.server.ServerJob.run(Unknown Source)
webviewer-server |      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
webviewer-server |      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
webviewer-server |      at java.lang.Thread.run(Thread.java:748)
webviewer-server | 09-Apr-2020 14:38:22.812 WARNING [pool-2-thread-4] com.pdftron.server.ServerJob.run During job id (/usr/local/apache-tomcat/static_data/Image/Fetched/4XAIzCDauayBoDmSiovlh4f6tcgVwzeZ4NVrpZjKxUA=2.pdf_dir/pageinfo.json):
webviewer-server | Exception during job run of type pages
webviewer-server |  java.lang.Exception: WebViewer Server complete job (/usr/local/apache-tomcat/static_data/Image/Fetched/4XAIzCDauayBoDmSiovlh4f6tcgVwzeZ4NVrpZjKxUA=2.pdf_dir/pageinfo.json) failed: unable to complete fetch of http://localhost:8080/secured/fileContent/2?downloadFile=false
webviewer-server | Connection refused (Connection refused)
webviewer-server |      at com.pdftron.server.ServerJob.run(Unknown Source)
webviewer-server |      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
webviewer-server |      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
webviewer-server |      at java.lang.Thread.run(Thread.java:748)
webviewer-server | Closing ws connection from endpoint: CloseReason: code [1001], reason [null]
webviewer-server | 09-Apr-2020 14:39:06.386 INFO [http-apr-8090-exec-4] com.pdftron.server.ConnectionService$Connection.onCloseImpl Closing Connection, 0 outstanding

现在“?downloadFile=false”部分有点误导,但它实际上并没有停止文件获取。 所有服务都在我的本地主机上 运行。只是 webviewer 容器是 运行 在 course.Which 的 docker 容器中是用 docker-compose up 命令启动的。而且它似乎无法从容器调用本地主机服务。 日志没有显示在服务中,Webviewer 只是说连接被拒绝。

第一次尝试时,我尝试从同一个 url 中获取带有数组缓冲区的文件,并且成功了。当然,在那种情况下,现在也在本地主机上 运行 的前端可以获取文件,我可以在前端显示文件。

但是我一添加服务器,服务器就无法访问该服务。 这也是我在前端配置文件读取的方式 angular app

const configWebViewer = {
  pdftronServer: serverUrlWithoutPort + ':8090/',
  path: '../../../../../../../../../../assets/webviewer',
  withCredentials: true,
  initialDoc: fileUrl,
}
WebViewer(configWebViewer, this.viewer.nativeElement)

现在另一件事是,出于某种原因,我在控制台中收到一条警告,指出 "withCredentials" 未知 属性。

我整天都在看这个,虽然我还在尝试,但我不确定还能做什么。因此,如果有任何我可以获得的信息,也许是我的疏忽或将不胜感激的事情。

亲切的问候

对于可能遇到与我相同或相似情况的任何人。 问题当然是 'localhost'。 我的所有服务都是 运行 在同一个 docker 组合中。所以他们在我认为 docker-compose 为他们创建的同一个网络上。

我将容器名称 url 中的 'localhost' 更改为 'myService' docker-compose 文件中的定义方式。 因此,webviewer 服务器能够通过我提供的 url 从服务中检索文件。

这个问题不应该出现在deployment/production之类的地方。因为在那种情况下,您并不是 运行 本地主机等中的所有内容。

这只是在本地有问题,因为我正在尝试测试 PdfTron。

我还没有真正解决的另一个问题是,因为我在 docker 容器中启动服务,所以我无法调试该服务。 当然,在某些情况下,我需要在 PdfTron 中查看文件并调试该服务。

但也许 docker-compose 创建网络的方式可能是我可以尝试的。 无论哪种方式,我都希望这可以帮助遇到此问题的任何人。