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
163 stars 25 forks source link

Target Directory not set correctly when using docker? #887

Closed Mawiguk0 closed 6 months ago

Mawiguk0 commented 7 months ago

The target directory is not set properly or the doc needs to be checked.

Device: HP Officejet Pro 8600 N911a Command line or Docker : Docker

docker-compose.yml with environement DIR="/scan" but logs of the container saying: node-hp-scan-to | Target folder: /tmp/scan-to-pcnLIIdn node-hp-scan-to | Temp folder: /tmp/scan-to-pchgfLJd

inside the container output of top: 60 58 node S 10.3g 67% 12 0% node index.js -d /scan -ip 192.168.181.17 -p '"scan"_yyyy.mm.dd_hh:MM:ss' so i assume that the directory is kind of set, but the app is not using the set directory.

...
  node-hp-scan-to:
    image: manuc66/node-hp-scan-to:master
    container_name: node-hp-scan-to
    hostname: paperless-ngx
    environment:
      - IP=192.168.181.17
      - LABEL="Paperless-NGX"
      - PATTERN='"scan"_yyyy.mm.dd_hh:MM:ss'
      - PGID=1000
      - PUID=1000
      - TZ=Europe/Berlin
      - RESOLUTION=600
      - DIR="/scan"
      - CMDLINE="-D"
    volumes:
      - ./data:/scan
    restart: always
...

Please attach the output with debug (-D switch, see documentation)

node-hp-scan-to  | s6-rc: info: service s6rc-oneshot-runner: starting
node-hp-scan-to  | s6-rc: info: service s6rc-oneshot-runner successfully started
node-hp-scan-to  | s6-rc: info: service fix-attrs: starting
node-hp-scan-to  | s6-rc: info: service fix-attrs successfully started
node-hp-scan-to  | s6-rc: info: service legacy-cont-init: starting
node-hp-scan-to  | cont-init: info: running /etc/cont-init.d/10-adduser
node-hp-scan-to  | usermod: no changes
node-hp-scan-to  | 
node-hp-scan-to  | User uid:    1000
node-hp-scan-to  | User gid:    1000
node-hp-scan-to  | -------------------------------------
node-hp-scan-to  | 
node-hp-scan-to  | s6-rc: fatal: timed out
node-hp-scan-to  | s6-sudoc: fatal: unable to get exit status from server: Operation timed out
node-hp-scan-to  | Starting
node-hp-scan-to  | WARNING: NODE_ENV value of 'production' did not match any deployment config file names.
node-hp-scan-to  | WARNING: See https://github.com/node-config/node-config/wiki/Strict-Mode
node-hp-scan-to  | WARNING: No configurations found in configuration directory:/app/config
node-hp-scan-to  | WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
node-hp-scan-to  | Using device ip: 192.168.181.17
node-hp-scan-to  | Target folder: /tmp/scan-to-pcoghNjG
node-hp-scan-to  | Temp folder: /tmp/scan-to-pcJPinng
node-hp-scan-to  | AxiosError: Request failed with status code 403
node-hp-scan-to  |     at settle (/app/node_modules/axios/dist/node/axios.cjs:1900:12)
node-hp-scan-to  |     at IncomingMessage.handleStreamEnd (/app/node_modules/axios/dist/node/axios.cjs:2952:11)
node-hp-scan-to  |     at IncomingMessage.emit (node:events:525:35)
node-hp-scan-to  |     at endReadableNT (node:internal/streams/readable:1359:12)
node-hp-scan-to  |     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
node-hp-scan-to  |   code: 'ERR_BAD_REQUEST',
node-hp-scan-to  |   config: {
node-hp-scan-to  |     transitional: {
node-hp-scan-to  |       silentJSONParsing: true,
node-hp-scan-to  |       forcedJSONParsing: true,
node-hp-scan-to  |       clarifyTimeoutError: false
node-hp-scan-to  |     },
node-hp-scan-to  |     adapter: [ 'xhr', 'http' ],
node-hp-scan-to  |     transformRequest: [ [Function: transformRequest] ],
node-hp-scan-to  |     transformResponse: [ [Function: transformResponse] ],
node-hp-scan-to  |     timeout: 0,
node-hp-scan-to  |     xsrfCookieName: 'XSRF-TOKEN',
node-hp-scan-to  |     xsrfHeaderName: 'X-XSRF-TOKEN',
node-hp-scan-to  |     maxContentLength: -1,
node-hp-scan-to  |     maxBodyLength: -1,
node-hp-scan-to  |     env: { FormData: [Function], Blob: [class Blob] },
node-hp-scan-to  |     validateStatus: [Function: validateStatus],
node-hp-scan-to  |     headers: AxiosHeaders {
node-hp-scan-to  |       Accept: 'application/json, text/plain, */*',
node-hp-scan-to  |       'User-Agent': 'axios/1.3.4',
node-hp-scan-to  |       'Accept-Encoding': 'gzip, compress, deflate, br'
node-hp-scan-to  |     },
node-hp-scan-to  |     baseURL: 'http://192.168.181.17',
node-hp-scan-to  |     url: '/DevMgmt/DiscoveryTree.xml',
node-hp-scan-to  |     method: 'get',
node-hp-scan-to  |     responseType: 'text',
node-hp-scan-to  |     data: undefined
node-hp-scan-to  |   },
node-hp-scan-to  |   request: <ref *1> ClientRequest {
node-hp-scan-to  |     _events: [Object: null prototype] {
node-hp-scan-to  |       abort: [Function (anonymous)],
node-hp-scan-to  |       aborted: [Function (anonymous)],
node-hp-scan-to  |       connect: [Function (anonymous)],
node-hp-scan-to  |       error: [Function (anonymous)],
node-hp-scan-to  |       socket: [Function (anonymous)],
node-hp-scan-to  |       timeout: [Function (anonymous)],
node-hp-scan-to  |       finish: [Function: requestOnFinish]
node-hp-scan-to  |     },
node-hp-scan-to  |     _eventsCount: 7,
node-hp-scan-to  |     _maxListeners: undefined,
node-hp-scan-to  |     outputData: [],
node-hp-scan-to  |     outputSize: 0,
node-hp-scan-to  |     writable: true,
node-hp-scan-to  |     destroyed: false,
node-hp-scan-to  |     _last: true,
node-hp-scan-to  |     chunkedEncoding: false,
node-hp-scan-to  |     shouldKeepAlive: false,
node-hp-scan-to  |     maxRequestsOnConnectionReached: false,
node-hp-scan-to  |     _defaultKeepAlive: true,
node-hp-scan-to  |     useChunkedEncodingByDefault: false,
node-hp-scan-to  |     sendDate: false,
node-hp-scan-to  |     _removedConnection: false,
node-hp-scan-to  |     _removedContLen: false,
node-hp-scan-to  |     _removedTE: false,
node-hp-scan-to  |     strictContentLength: false,
node-hp-scan-to  |     _contentLength: 0,
node-hp-scan-to  |     _hasBody: true,
node-hp-scan-to  |     _trailer: '',
node-hp-scan-to  |     finished: true,
node-hp-scan-to  |     _headerSent: true,
node-hp-scan-to  |     _closed: false,
node-hp-scan-to  |     socket: Socket {
node-hp-scan-to  |       connecting: false,
node-hp-scan-to  |       _hadError: false,
node-hp-scan-to  |       _parent: null,
node-hp-scan-to  |       _host: null,
node-hp-scan-to  |       _closeAfterHandlingError: false,
node-hp-scan-to  |       _readableState: [ReadableState],
node-hp-scan-to  |       _events: [Object: null prototype],
node-hp-scan-to  |       _eventsCount: 8,
node-hp-scan-to  |       _maxListeners: undefined,
node-hp-scan-to  |       _writableState: [WritableState],
node-hp-scan-to  |       allowHalfOpen: false,
node-hp-scan-to  |       _sockname: null,
node-hp-scan-to  |       _pendingData: null,
node-hp-scan-to  |       _pendingEncoding: '',
node-hp-scan-to  |       server: null,
node-hp-scan-to  |       _server: null,
node-hp-scan-to  |       parser: null,
node-hp-scan-to  |       _httpMessage: [Circular *1],
node-hp-scan-to  |       write: [Function: writeAfterFIN],
node-hp-scan-to  |       [Symbol(async_id_symbol)]: 23,
node-hp-scan-to  |       [Symbol(kHandle)]: null,
node-hp-scan-to  |       [Symbol(lastWriteQueueSize)]: 0,
node-hp-scan-to  |       [Symbol(timeout)]: null,
node-hp-scan-to  |       [Symbol(kBuffer)]: null,
node-hp-scan-to  |       [Symbol(kBufferCb)]: null,
node-hp-scan-to  |       [Symbol(kBufferGen)]: null,
node-hp-scan-to  |       [Symbol(kCapture)]: false,
node-hp-scan-to  |       [Symbol(kSetNoDelay)]: true,
node-hp-scan-to  |       [Symbol(kSetKeepAlive)]: true,
node-hp-scan-to  |       [Symbol(kSetKeepAliveInitialDelay)]: 60,
node-hp-scan-to  |       [Symbol(kBytesRead)]: 674,
node-hp-scan-to  |       [Symbol(kBytesWritten)]: 198
node-hp-scan-to  |     },
node-hp-scan-to  |     _header: 'GET /DevMgmt/DiscoveryTree.xml HTTP/1.1\r\n' +
node-hp-scan-to  |       'Accept: application/json, text/plain, */*\r\n' +
node-hp-scan-to  |       'User-Agent: axios/1.3.4\r\n' +
node-hp-scan-to  |       'Accept-Encoding: gzip, compress, deflate, br\r\n' +
node-hp-scan-to  |       'Host: 192.168.181.17\r\n' +
node-hp-scan-to  |       'Connection: close\r\n' +
node-hp-scan-to  |       '\r\n',
node-hp-scan-to  |     _keepAliveTimeout: 0,
node-hp-scan-to  |     _onPendingData: [Function: nop],
node-hp-scan-to  |     agent: Agent {
node-hp-scan-to  |       _events: [Object: null prototype],
node-hp-scan-to  |       _eventsCount: 2,
node-hp-scan-to  |       _maxListeners: undefined,
node-hp-scan-to  |       defaultPort: 80,
node-hp-scan-to  |       protocol: 'http:',
node-hp-scan-to  |       options: [Object: null prototype],
node-hp-scan-to  |       requests: [Object: null prototype] {},
node-hp-scan-to  |       sockets: [Object: null prototype],
node-hp-scan-to  |       freeSockets: [Object: null prototype] {},
node-hp-scan-to  |       keepAliveMsecs: 1000,
node-hp-scan-to  |       keepAlive: false,
node-hp-scan-to  |       maxSockets: Infinity,
node-hp-scan-to  |       maxFreeSockets: 256,
node-hp-scan-to  |       scheduling: 'lifo',
node-hp-scan-to  |       maxTotalSockets: Infinity,
node-hp-scan-to  |       totalSocketCount: 1,
node-hp-scan-to  |       [Symbol(kCapture)]: false
node-hp-scan-to  |     },
node-hp-scan-to  |     socketPath: undefined,
node-hp-scan-to  |     method: 'GET',
node-hp-scan-to  |     maxHeaderSize: undefined,
node-hp-scan-to  |     insecureHTTPParser: undefined,
node-hp-scan-to  |     joinDuplicateHeaders: undefined,
node-hp-scan-to  |     path: '/DevMgmt/DiscoveryTree.xml',
node-hp-scan-to  |     _ended: true,
node-hp-scan-to  |     res: IncomingMessage {
node-hp-scan-to  |       _readableState: [ReadableState],
node-hp-scan-to  |       _events: [Object: null prototype],
node-hp-scan-to  |       _eventsCount: 4,
node-hp-scan-to  |       _maxListeners: undefined,
node-hp-scan-to  |       socket: [Socket],
node-hp-scan-to  |       httpVersionMajor: 1,
node-hp-scan-to  |       httpVersionMinor: 0,
node-hp-scan-to  |       httpVersion: '1.0',
node-hp-scan-to  |       complete: true,
node-hp-scan-to  |       rawHeaders: [Array],
node-hp-scan-to  |       rawTrailers: [],
node-hp-scan-to  |       joinDuplicateHeaders: undefined,
node-hp-scan-to  |       aborted: false,
node-hp-scan-to  |       upgrade: false,
node-hp-scan-to  |       url: '',
node-hp-scan-to  |       method: null,
node-hp-scan-to  |       statusCode: 403,
node-hp-scan-to  |       statusMessage: 'connecting to 192.168.181.17:80: connecting to 192.168.181.17:80: dial tcp 192.168.181.17:80: connectex: Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat.',
node-hp-scan-to  |       client: [Socket],
node-hp-scan-to  |       _consuming: true,
node-hp-scan-to  |       _dumped: false,
node-hp-scan-to  |       req: [Circular *1],
node-hp-scan-to  |       responseUrl: 'http://192.168.181.17/DevMgmt/DiscoveryTree.xml',
node-hp-scan-to  |       redirects: [],
node-hp-scan-to  |       [Symbol(kCapture)]: false,
node-hp-scan-to  |       [Symbol(kHeaders)]: [Object],
node-hp-scan-to  |       [Symbol(kHeadersCount)]: 2,
node-hp-scan-to  |       [Symbol(kTrailers)]: null,
node-hp-scan-to  |       [Symbol(kTrailersCount)]: 0
node-hp-scan-to  |     },
node-hp-scan-to  |     aborted: false,
node-hp-scan-to  |     timeoutCb: null,
node-hp-scan-to  |     upgradeOrConnect: false,
node-hp-scan-to  |     parser: null,
node-hp-scan-to  |     maxHeadersCount: null,
node-hp-scan-to  |     reusedSocket: false,
node-hp-scan-to  |     host: '192.168.181.17',
node-hp-scan-to  |     protocol: 'http:',
node-hp-scan-to  |     _redirectable: Writable {
node-hp-scan-to  |       _writableState: [WritableState],
node-hp-scan-to  |       _events: [Object: null prototype],
node-hp-scan-to  |       _eventsCount: 3,
node-hp-scan-to  |       _maxListeners: undefined,
node-hp-scan-to  |       _options: [Object],
node-hp-scan-to  |       _ended: true,
node-hp-scan-to  |       _ending: true,
node-hp-scan-to  |       _redirectCount: 0,
node-hp-scan-to  |       _redirects: [],
node-hp-scan-to  |       _requestBodyLength: 0,
node-hp-scan-to  |       _requestBodyBuffers: [],
node-hp-scan-to  |       _onNativeResponse: [Function (anonymous)],
node-hp-scan-to  |       _currentRequest: [Circular *1],
node-hp-scan-to  |       _currentUrl: 'http://192.168.181.17/DevMgmt/DiscoveryTree.xml',
node-hp-scan-to  |       [Symbol(kCapture)]: false
node-hp-scan-to  |     },
node-hp-scan-to  |     [Symbol(kCapture)]: false,
node-hp-scan-to  |     [Symbol(kBytesWritten)]: 0,
node-hp-scan-to  |     [Symbol(kEndCalled)]: true,
node-hp-scan-to  |     [Symbol(kNeedDrain)]: false,
node-hp-scan-to  |     [Symbol(corked)]: 0,
node-hp-scan-to  |     [Symbol(kOutHeaders)]: [Object: null prototype] {
node-hp-scan-to  |       accept: [Array],
node-hp-scan-to  |       'user-agent': [Array],
node-hp-scan-to  |       'accept-encoding': [Array],
node-hp-scan-to  |       host: [Array]
node-hp-scan-to  |     },
node-hp-scan-to  |     [Symbol(errored)]: null,
node-hp-scan-to  |     [Symbol(kUniqueHeaders)]: null
node-hp-scan-to  |   },
node-hp-scan-to  |   response: {
node-hp-scan-to  |     status: 403,
node-hp-scan-to  |     statusText: 'connecting to 192.168.181.17:80: connecting to 192.168.181.17:80: dial tcp 192.168.181.17:80: connectex: Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat.',
node-hp-scan-to  |     headers: AxiosHeaders { connection: 'close' },
node-hp-scan-to  |     config: {
node-hp-scan-to  |       transitional: [Object],
node-hp-scan-to  |       adapter: [Array],
node-hp-scan-to  |       transformRequest: [Array],
node-hp-scan-to  |       transformResponse: [Array],
node-hp-scan-to  |       timeout: 0,
node-hp-scan-to  |       xsrfCookieName: 'XSRF-TOKEN',
node-hp-scan-to  |       xsrfHeaderName: 'X-XSRF-TOKEN',
node-hp-scan-to  |       maxContentLength: -1,
node-hp-scan-to  |       maxBodyLength: -1,
node-hp-scan-to  |       env: [Object],
node-hp-scan-to  |       validateStatus: [Function: validateStatus],
node-hp-scan-to  |       headers: [AxiosHeaders],
node-hp-scan-to  |       baseURL: 'http://192.168.181.17',
node-hp-scan-to  |       url: '/DevMgmt/DiscoveryTree.xml',
node-hp-scan-to  |       method: 'get',
node-hp-scan-to  |       responseType: 'text',
node-hp-scan-to  |       data: undefined
node-hp-scan-to  |     },
node-hp-scan-to  |     request: <ref *1> ClientRequest {
node-hp-scan-to  |       _events: [Object: null prototype],
node-hp-scan-to  |       _eventsCount: 7,
node-hp-scan-to  |       _maxListeners: undefined,
node-hp-scan-to  |       outputData: [],
node-hp-scan-to  |       outputSize: 0,
node-hp-scan-to  |       writable: true,
node-hp-scan-to  |       destroyed: false,
node-hp-scan-to  |       _last: true,
node-hp-scan-to  |       chunkedEncoding: false,
node-hp-scan-to  |       shouldKeepAlive: false,
node-hp-scan-to  |       maxRequestsOnConnectionReached: false,
node-hp-scan-to  |       _defaultKeepAlive: true,
node-hp-scan-to  |       useChunkedEncodingByDefault: false,
node-hp-scan-to  |       sendDate: false,
node-hp-scan-to  |       _removedConnection: false,
node-hp-scan-to  |       _removedContLen: false,
node-hp-scan-to  |       _removedTE: false,
node-hp-scan-to  |       strictContentLength: false,
node-hp-scan-to  |       _contentLength: 0,
node-hp-scan-to  |       _hasBody: true,
node-hp-scan-to  |       _trailer: '',
node-hp-scan-to  |       finished: true,
node-hp-scan-to  |       _headerSent: true,
node-hp-scan-to  |       _closed: false,
node-hp-scan-to  |       socket: [Socket],
node-hp-scan-to  |       _header: 'GET /DevMgmt/DiscoveryTree.xml HTTP/1.1\r\n' +
node-hp-scan-to  |         'Accept: application/json, text/plain, */*\r\n' +
node-hp-scan-to  |         'User-Agent: axios/1.3.4\r\n' +
node-hp-scan-to  |         'Accept-Encoding: gzip, compress, deflate, br\r\n' +
node-hp-scan-to  |         'Host: 192.168.181.17\r\n' +
node-hp-scan-to  |         'Connection: close\r\n' +
node-hp-scan-to  |         '\r\n',
node-hp-scan-to  |       _keepAliveTimeout: 0,
node-hp-scan-to  |       _onPendingData: [Function: nop],
node-hp-scan-to  |       agent: [Agent],
node-hp-scan-to  |       socketPath: undefined,
node-hp-scan-to  |       method: 'GET',
node-hp-scan-to  |       maxHeaderSize: undefined,
node-hp-scan-to  |       insecureHTTPParser: undefined,
node-hp-scan-to  |       joinDuplicateHeaders: undefined,
node-hp-scan-to  |       path: '/DevMgmt/DiscoveryTree.xml',
node-hp-scan-to  |       _ended: true,
node-hp-scan-to  |       res: [IncomingMessage],
node-hp-scan-to  |       aborted: false,
node-hp-scan-to  |       timeoutCb: null,
node-hp-scan-to  |       upgradeOrConnect: false,
node-hp-scan-to  |       parser: null,
node-hp-scan-to  |       maxHeadersCount: null,
node-hp-scan-to  |       reusedSocket: false,
node-hp-scan-to  |       host: '192.168.181.17',
node-hp-scan-to  |       protocol: 'http:',
node-hp-scan-to  |       _redirectable: [Writable],
node-hp-scan-to  |       [Symbol(kCapture)]: false,
node-hp-scan-to  |       [Symbol(kBytesWritten)]: 0,
node-hp-scan-to  |       [Symbol(kEndCalled)]: true,
node-hp-scan-to  |       [Symbol(kNeedDrain)]: false,
node-hp-scan-to  |       [Symbol(corked)]: 0,
node-hp-scan-to  |       [Symbol(kOutHeaders)]: [Object: null prototype],
node-hp-scan-to  |       [Symbol(errored)]: null,
node-hp-scan-to  |       [Symbol(kUniqueHeaders)]: null
node-hp-scan-to  |     },
node-hp-scan-to  |     data: 'connecting to 192.168.181.17:80: connecting to 192.168.181.17:80: dial tcp 192.168.181.17:80: connectex: Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat.'
node-hp-scan-to  |   }
node-hp-scan-to  | }
node-hp-scan-to  | s6-rc: info: service fix-attrs: stopping
node-hp-scan-to  | s6-rc: info: service fix-attrs successfully stopped
node-hp-scan-to  | s6-rc: info: service s6rc-oneshot-runner: stopping
node-hp-scan-to  | s6-rc: info: service s6rc-oneshot-runner successfully stopped
Mawiguk0 commented 7 months ago

For now as a quick fix, I changed the index.ts so that it does not use the PathHelper for the directory.

Things seem odd with the parameter handling. Will look into it later

Tche333 commented 6 months ago

When working with this application in a container, the application default directory (as specified in app.sh) is /scan and doesn't need to be changed. node application is thus still using /scan to store scan file. You then use the Volume directive from compose file to map /scan to your preferred host directory I've used the Volume in compose file to point where scan files should be stored outside the container

volumes:
 - <absolute or relative directory path on host>:/scan:rw

From your compose file exposed above, is data directory (specified as a relative path) existing in the directory where you started the application, using docker compose ? That should be the place where scan docs are stored.

bbrouwers commented 6 months ago

I'm facing a similar issue. I'm running this cool project using Docker on a Synology NAS. Before I upgraded everything, everything ran smoothly. However currently no scans are saved to the mounted /scan path. Whenever I sh into the container docker exec -it <container> sh I'm able to create files in the /scan directory and see them to appear in the correct folder on the host. This means imho that the volumes are mounted correctly in the container but for some reason the container cannot use it?

Just like @Mawiguk0 I see the following in the log output:

Temp folder: /tmp/scan-to-pcndkBgI
Target folder: /tmp/scan-to-pcapBAHf

Even whilest the /scan mount is correctly configured per Docker configuration.

Is there a fix or workaround available to overcome this issue?

manuc66 commented 6 months ago

Hello

Could you tell me if you face the same issue with

image: manuc66/node-hp-scan-to:latest

I mean by using latest instead of master ? (The master tag has unfortunately not been updated recently and there was a fix for a simiar issue https://github.com/manuc66/node-hp-scan-to/issues/644)

bbrouwers commented 6 months ago

Hi, thanks for your prompt reply! I've tested latest and can confirm it then works as expected! Thank you.

manuc66 commented 6 months ago

The master tag should be updated now