manuc66 / node-hp-scan-to

Allow to send scan from device to computer for some HP All-in-One Printers - Scan to computer
https://manuc66.github.io/node-hp-scan-to/
MIT License
153 stars 23 forks source link

Paperless problem (no data transfer) #936

Closed DanielR92 closed 1 month ago

DanielR92 commented 1 month ago

Hello,

I use Paperless with an HP OfficeJet Pro 6960 printer. I set everything up as follows (environment variables):

PAPERLESS_TOKEN: xxxxxxxxxx generated from paperless PAPERLESS_HOST: 192.168.10.5:8000

When I start Docker I get the following message, I hope you can help me here:

s6-rc: info: service legacy-cont-init successfully started

s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
WARNING: NODE_ENV value of 'production' did not match any deployment config file names.
Starting
WARNING: See https://github.com/node-config/node-config/wiki/Strict-Mode
WARNING: No configurations found in configuration directory:/app/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
Using device ip: 192.168.10.253
Target folder: /scan
Temp folder: /tmp/scan-to-pcEpNCPp
Running iteration: 1 - errorCount: 0
Host destinations fetched: Paperless
Re-using existing destination: Paperless - /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Using: Paperless
Waiting scan event for: /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Start listening for new ScanEvent

There is no message from Paperless. Using the debug output of "node-hp-scan-to" I also get no information about the API interface.

Where is the problem?

Thanks in Advance for your help. :) Greate Job!

manuc66 commented 1 month ago

Hello @DanielR92

It seems you didn't trigger the scan from the device

When I do it from my side I have this kind of output:

Using device ip: 192.168.y.z
Target folder: /tmp/scan-to-pce9QKoS
Temp folder: /tmp/scan-to-pcE2xGxl
Running iteration: 1 - errorCount: 0
Host destinations fetched: xxxx, paperless
Re-using existing destination: paperless - /WalkupScanToComp/WalkupScanToCompDestinations/cb3cff6c-a466-4ad5-9f3a-2b45a5f08271
Using: emmanuel-ms7850
Waiting scan event for: /WalkupScanToComp/WalkupScanToCompDestinations/cb3cff6c-a466-4ad5-9f3a-2b45a5f08271
Start listening for new ScanEvent
Scan event captured, saving scan #1
Waiting user input: 1/50
Waiting user input: 2/50
Waiting user input: 3/50
Selected shortcut: SaveJPEG
ScanPlexMode is : Simplex
Afd is : Empty
New job created: http://192.168.y.z:8080/Jobs/JobList/4
Ready to download page job page 1 at: /Scan/Jobs/4/Pages/1
Page downloaded to: /tmp/scan-to-pce9QKoS/scan1_page1.jpg
Job state: Completed, totalPages: 1:
Start listening for new ScanEvent
Scan of page(s) completed totalPages: 1:
        - page   1 - 1700x2338 - /tmp/scan-to-pce9QKoS/scan1_page1.jpg
Document successfully uploaded to paperless: 07ea01a3-320d-4c7c-9b2f-93cc39465e94
Pdf document /tmp/scan-to-pce9QKoS/scan1.pdf has removed from the filesystem
Running iteration: 2 - errorCount: 0
Host destinations fetched: xxxx, paperless
Re-using existing destination: paperless - /WalkupScanToComp/WalkupScanToCompDestinations/cb3cff6c-a466-4ad5-9f3a-2b45a5f08271
Using: emmanuel-ms7850
Waiting scan event for: /WalkupScanToComp/WalkupScanToCompDestinations/cb3cff6c-a466-4ad5-9f3a-2b45a5f08271
Start listening for new ScanEvent

Can you provide an updated version of the logs ?

DanielR92 commented 1 month ago

Im sorry, I have not written here. Yes of cause I started a scan (trigger).

That is the whole console:

text  error  warn  system  array  login  

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/10-adduser
groupmod: invalid group ID '"1000"'
usermod: invalid user ID '"1000"'
cont-init: info: /etc/cont-init.d/10-adduser exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
WARNING: NODE_ENV value of 'production' did not match any deployment config file names.
WARNING: See https://github.com/node-config/node-config/wiki/Strict-Mode
WARNING: No configurations found in configuration directory:/app/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.

User uid:    1000
User gid:    1000
-------------------------------------

Starting
Using device ip: 192.168.10.253
Target folder: /scan
Temp folder: /tmp/scan-to-pcEpNCPp
Running iteration: 1 - errorCount: 0
Host destinations fetched: Paperless
Re-using existing destination: Paperless - /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Using: Paperless
Waiting scan event for: /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Start listening for new ScanEvent
Scan event captured, saving scan #0
Waiting user input: 1/50
Waiting user input: 2/50
Selected shortcut: SavePDF
Scan will be converted to pdf, using /tmp/scan-to-pcEpNCPp as temp scan output directory for individual pages
ScanPlexMode is : Simplex
Afd is : Empty
New job created: http://192.168.10.253:8080/Jobs/JobList/8
Ready to download page job page 1 at: /Scan/Jobs/8/Pages/1
Page downloaded to: /tmp/scan-to-pcEpNCPp/scan_13.07.2024_09:51:50.jpg
Job state: Completed, totalPages: 1:
Start listening for new ScanEvent
Scan of page(s) completed totalPages: 1:
The following page(s) have been rendered inside '/tmp/scan-to-pcEpNCPp/scan_13.07.2024_09:51:47.pdf': 
        - page   1 - 1700x2366
Running iteration: 2 - errorCount: 0
Host destinations fetched: Paperless
Re-using existing destination: Paperless - /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Using: Paperless
Waiting scan event for: /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Start listening for new ScanEvent
manuc66 commented 1 month ago

@DanielR92 When using the Docker container I managed to reproduce the issue, it should be fixed now, can you tray again ?

DanielR92 commented 1 month ago

Good morning, in my case it is not working at now.

text  error  warn  system  array  login  

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/10-adduser
groupmod: invalid group ID '"1000"'
usermod: invalid user ID '"1000"'
cont-init: info: /etc/cont-init.d/10-adduser exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
WARNING: NODE_ENV value of 'production' did not match any deployment config file names.
WARNING: See https://github.com/node-config/node-config/wiki/Strict-Mode
WARNING: No configurations found in configuration directory:/app/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.

User uid:    1000
User gid:    1000
-------------------------------------

Starting
Using device ip: 192.168.10.253
Paperless configuration provided, host: 192.168.10.5:8000, the token length: 40, keepFiles: false
Target folder: /scan
Temp folder: /tmp/scan-to-pcaCfMlK
Running iteration: 1 - errorCount: 0
Host destinations fetched: Paperless
Re-using existing destination: Paperless - /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Using: Paperless
Waiting scan event for: /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Start listening for new ScanEvent
Scan event captured, saving scan #0
Waiting user input: 1/50
Waiting user input: 2/50
Selected shortcut: SavePDF
Scan will be converted to pdf, using /tmp/scan-to-pcaCfMlK as temp scan output directory for individual pages
ScanPlexMode is : Simplex
Afd is : Empty
New job created: http://192.168.10.253:8080/Jobs/JobList/9
Ready to download page job page 1 at: /Scan/Jobs/9/Pages/1
Page downloaded to: /tmp/scan-to-pcaCfMlK/scan_14.07.2024_08:03:22.jpg
Job state: Completed, totalPages: 1:
Start listening for new ScanEvent
Scan of page(s) completed totalPages: 1:
The following page(s) have been rendered inside '/tmp/scan-to-pcaCfMlK/scan_14.07.2024_08:03:18.pdf': 
        - page   1 - 1700x2366
Start uploading to paperless: /tmp/scan-to-pcaCfMlK/scan_14.07.2024_08:03:18.pdf
Fail to upload document: AxiosError: write EPROTO D839EE09BD140000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:354:

    at AxiosError.from (/app/node_modules/axios/dist/node/axios.cjs:841:14)
    at RedirectableRequest.handleRequestError (/app/node_modules/axios/dist/node/axios.cjs:3106:25)
    at RedirectableRequest.emit (node:events:529:35)
    at eventHandlers.<computed> (/app/node_modules/follow-redirects/index.js:38:24)
    at ClientRequest.emit (node:events:517:28)
    at TLSSocket.socketErrorListener (node:_http_client:501:9)
    at TLSSocket.emit (node:events:517:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at Axios.request (/app/node_modules/axios/dist/node/axios.cjs:4224:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async uploadToPaperless (/app/scanProcessing.js:352:26)
    at async postProcessing (/app/scanProcessing.js:274:17)
    at async saveScanFromEvent (/app/scanProcessing.js:342:5)
    at async listenCmd (/app/index.js:38:13)
    at async Command.<anonymous> (/app/index.js:237:9)
    at async Command.parseAsync (/app/node_modules/commander/lib/command.js:1092:5)
    at async main (/app/index.js:277:5) {
  syscall: 'write',
  code: 'EPROTO',
  errno: -71,
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [ 'xhr', 'http', 'fetch' ],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    env: { FormData: [Function], Blob: [class Blob] },
    validateStatus: [Function: validateStatus],
    headers: Object [AxiosHeaders] {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'multipart/form-data; boundary=--------------------------552109110235819243178172',
      Authorization: 'Token 54d1fd46f36a4b9e03b01ae4c59717b6feeddacd',
      'User-Agent': 'axios/1.7.2',
      'Content-Length': '160160',
      'Accept-Encoding': 'gzip, compress, deflate, br'
    },
    method: 'post',
    url: 'https://192.168.10.5:8000/api/documents/post_document/',
    data: FormData {
      _overheadLength: 179,
      _valueLength: 0,
      _valuesToMeasure: [Array],
      writable: true,
      readable: true,
      dataSize: 0,
      maxDataSize: 2097152,
      pauseStreams: true,
      _released: true,
      _streams: [Array],
      _currentStream: [DelayedStream],
      _insideLoop: false,
      _pendingNext: false,
      _boundary: '--------------------------552109110235819243178172',
      _events: [Object: null prototype],
      _eventsCount: 4
    }
  },
  request: <ref *1> Writable {
    _writableState: WritableState {
      objectMode: false,
      highWaterMark: 16384,
      finalCalled: false,
      needDrain: false,
      ending: false,
      ended: false,
      finished: false,
      destroyed: false,
      decodeStrings: true,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: true,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      afterWriteTickInfo: null,
      buffered: [],
      bufferedIndex: 0,
      allBuffers: true,
      allNoop: true,
      pendingcb: 0,
      constructed: true,
      prefinished: false,
      errorEmitted: false,
      emitClose: true,
      autoDestroy: true,
      errored: null,
      closed: false,
      closeEmitted: false,
      [Symbol(kOnFinished)]: []
    },
    _events: [Object: null prototype] {
      response: [Function: handleResponse],
      error: [Function: handleRequestError],
      socket: [Function: handleRequestSocket]
    },
    _eventsCount: 3,
    _maxListeners: undefined,
    _options: {
      maxRedirects: 21,
      maxBodyLength: Infinity,
      protocol: 'https:',
      path: '/api/documents/post_document/',
      method: 'POST',
      headers: [Object: null prototype],
      agents: [Object],
      auth: undefined,
      family: undefined,
      beforeRedirect: [Function: dispatchBeforeRedirect],
      beforeRedirects: [Object],
      hostname: '192.168.10.5',
      port: '8000',
      agent: undefined,
      nativeProtocols: [Object],
      pathname: '/api/documents/post_document/'
    },
    _ended: false,
    _ending: false,
    _redirectCount: 0,
    _redirects: [],
    _requestBodyLength: 65713,
    _requestBodyBuffers: [ [Object], [Object] ],
    _onNativeResponse: [Function (anonymous)],
    _currentRequest: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: '160160',
      _hasBody: true,
      _trailer: '',
      finished: false,
      _headerSent: true,
      _closed: false,
      socket: [TLSSocket],
      _header: 'POST /api/documents/post_document/ HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: multipart/form-data; boundary=--------------------------552109110235819243178172\r\n' +
        'Authorization: Token 54d1fd46f36a4b9e03b01ae4c59717b6feeddacd\r\n' +
        'User-Agent: axios/1.7.2\r\n' +
        'Content-Length: 160160\r\n' +
        'Accept-Encoding: gzip, compress, deflate, br\r\n' +
        'Host: 192.168.10.5:8000\r\n' +
Pdf document /tmp/scan-to-pcaCfMlK/scan_14.07.2024_08:03:18.pdf has removed from the filesystem
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'POST',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/api/documents/post_document/',
      _ended: false,
      res: null,
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: '192.168.10.5',
      protocol: 'https:',
      _redirectable: [Circular *1],
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: true,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    _currentUrl: 'https://192.168.10.
'5:8000/api/documents/post_document/',
    [Symbol(kCapture)]: false
  },
  cause: Error: write EPROTO D839EE09BD140000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:354:

      at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16) {
    errno: -71,
    code: 'EPROTO',
    syscall: 'write'
  }
}
Running iteration: 2 - errorCount: 0
Host destinations fetched: Paperless
Re-using existing destination: Paperless - /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Using: Paperless
Waiting scan event for: /WalkupScanToComp/WalkupScanToCompDestinations/1c852f2e-b814-1f08-9d59-ec8eb56c9dfd
Start listening for new ScanEvent

I will check too the issue here. When I have some other information, I will tell it here. Thanks

manuc66 commented 1 month ago

@DanielR92 I think it's due to the fact that I only allowed to change the host name which is a bad choice because it would prevent you from using http instead of http or having the hosting under a different path location

939 aim to fix that

The new docker way to configure is with the following environnement variables :

DanielR92 commented 1 month ago

Hmm is not working. When I do it manualy over "http://ip:8000/api/documents/post_document/" it working great.

My configuration its now so: PAPERLESS_TOKEN: ** PAPERLESS_POST_DOCUMENT_URL: "ip:8000/api/documents/post_document/"

Should be correct? Because you removed from the source code the path correct?

  _ending: false,
    _redirectCount: 0,
    _redirects: [],
    _requestBodyLength: 65713,
    _requestBodyBuffers: [ [Object], [Object] ],
    _onNativeResponse: [Function (anonymous)],
    _currentRequest: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: '159760',
      _hasBody: true,
      _trailer: '',
      finished: false,
      _headerSent: true,
      _closed: false,
      socket: [Socket],
      _header: 'POST /192.168.10.5:8000/api/documents/post_document/ HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: multipart/form-data; boundary=--------------------------129719888717485276099343\r\n' +
        'Authorization: Token 54d1fd46f36a4b9e03b01ae4c59717b6feeddacd\r\n' +
        'User-Agent: axios/1.7.2\r\n' +
        'Content-Length: 159760\r\n' +
        'Accept-Encoding: gzip, compress, deflate, br\r\n' +
        'Host: localhost\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'POST',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/192.168.10.5:8000/api/documents/post_document/',
      _ended: false,
      res: null,
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'localhost',
      protocol: 'http:',
      _redirectable: [Circular *1],
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: true,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    _currentUrl: 'http://localhost/192.168.10.5:8000/api/documents/post_document/',
    [Symbol(kCapture)]: false
  },
  cause: Error: connect ECONNREFUSED ::1:80
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '::1',
    port: 80
  }
}
manuc66 commented 1 month ago

This parameter should be like this:

PAPERLESS_POST_DOCUMENT_URL= "http://192.168.10.5:8000/api/documents/post_document/"

You seem to have forgotten this part: 'http://'

I removed the path and the protocol because the error you had previously was because the program was trying to reach with https but your endpoint is http

DanielR92 commented 1 month ago

Yes it working now! :) Thanks for this huge improvment.

I write a PR, when it is nice for you. https://github.com/manuc66/node-hp-scan-to/pull/940